0

this is my jquery code.year is form input tag id.years is array variable it's contain all years values.i put this array in autocomplete source.it's working fine.but once i set autocomplete source equal null after set autocomplete source years array did not work.how to solve this problem?

$("#year").blur(function() {
    var keyEvent = $.Event("keydown");
    keyEvent.keyCode = $.ui.keyCode.ENTER;
    $(this).trigger(keyEvent);
    // Stop event propagation if needed
    return false;
}).autocomplete({
    autoFocus : true,
    source : years,
    selectFirst : true,
    select : function(event, ui) {
        variableyear = (ui.item.lable);
    }
});

code for clear source data:

$("#year").autocomplete('option', 'source', null);
1
  • 1
    It's really hurt my eyes for reading your question. Could you give a little effort to correct your format (upper cases, indent...)? Commented Jun 7, 2014 at 17:11

1 Answer 1

3

Try setting an empty array as the source:

$("#year").autocomplete({source: []});

or

$("#year").autocomplete('option', 'source', []);
Sign up to request clarification or add additional context in comments.

1 Comment

Did you try both of them?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.