Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8554579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:54:53+00:00 2026-06-11T14:54:53+00:00

I have a form that tracks items allowed in certain places on campus. A

  • 0

I have a form that tracks items allowed in certain places on campus. A radio button group controls whether the area in question is a physical room or a more genearl ‘project’. Either one has its value entered into the same field in the database.

Rooms and projects are stored in separate tables. I want to take advantage of jQuery UI’s auto-complete here. So far, the change event on the radio group switches the appropriate text for room and project, and toggles the class ‘roomAC’. The ‘roomAC’ class is the selector for the auto-complete.

I figured when I removed the class it would no longer let the auto-complete work, but it does. This is because the event is still bound to the DOM element. What I want to know is if there is a way to bind/unbind the auto-complete event? Or am I stuck re-creating the event-handler inside my if statement (the one the radio group)?

MY JS

//ROOM FIELD JQUERY-UI AUTO-COMPLETE
$(".roomAC").autocomplete({
    source: "autocomplete.cfm",
    minLength: 4
});

tl;dr

How do I bind and unbind the jQuery UI auto-complete event?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:54:55+00:00Added an answer on June 11, 2026 at 2:54 pm

    Regarding your question about unbinding autocomplete control, you could either disable it or change source with .autocomplete( "option" , optionName , [value] ) syntax.

    But if I understand your situation correctly, you actually want to send both the search term and source identifier. It could be achieved by using callback as source (in your autocomplete options). Documentation says:

    The third variation, the callback, provides the most flexibility, and
    can be used to connect any data source to Autocomplete. The callback
    gets two arguments:

    A request object, with a single property called “term”, which refers
    to the value currently in the text input. For example, when the user
    entered “new yo” in a city field, the Autocomplete term will equal
    “new yo”.

    A response callback, which expects a single argument to
    contain the data to suggest to the user. This data should be filtered
    based on the provided term, and can be in any of the formats described
    above for simple local data (String-Array or Object-Array with
    label/value/both properties). It’s important when providing a custom
    source callback to handle errors during the request. You must always
    call the response callback even if you encounter an error. This
    ensures that the widget always has the correct state.

    This is function I have used with jQuery UI autocomplete:

    function initSuggest(){
        var cache = {},
            lastXhr;
        $( ".Mjesto" ).each( function() {
            $( this ).autocomplete( {
                minLength: 2,
                source: function( request, response ) {
                    var sourceId = $("#DrzavaId option:selected").text();
                    var term = request.term;
                    if ( term in cache ) {
                        response( cache[term] );
                    } else {
                        try {
                            lastXhr = $.getJSON( "autocomplete2.cfm", { c: sourceId, t: term }, 
                                function( data, status, xhr ) {
                                    cache[term] = data;
                                    if ( xhr === lastXhr ) {
                                    response( data );
                                }
                            });
                        } catch( ex ) {
                            response( null );
                        }
                    }
                },
                autoFocus: true
            } );
        } );
    }
    

    This function also caches response. If you ignore that, the trick is within try/catch block.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that jQuery tracks the onChage .change() event so when something
I have a string that should contain a list of items in the form
I currently have form that checks if a user has unsubmitted changes when they
I have a form that I'm submitting through AJAX. The form includes many fields,
I have a form that I want to be validated before showing it initially.
I have a form that sends money value e.g <input type=text name=amount value=N50,000.00 NGN
I have a form that includes the first name and last name of a
I have a form that has label values that I would like to pass
I have a form that the user submits and returns a result, but it
I have a form that i want to appear at the top of every

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.