2

So I have the following code:

jQuery('#id').live('keyup.autocomplete', function () {
    jQuery(this).autocomplete({
        source: function (request, response) {
            jQuery.getJSON("link?callback=?", {
                format: 'jsonp',
                ...
            }, response);
        },
        minLength: 2,
        selectFirst: true,
        select: function (event, ui) {
                ...
        }
    })
});

In Firefox when I try to use the input it give me:

TypeError: jQuery(this).autocomplete is not a function
[Break On This Error]   

select: function( event, ui ) {

This error is only in Firefox, on all other browsers it works all fine. Any ideas?

1

1 Answer 1

4

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().

$(selector).live(events, data, handler); // jQuery 1.3+

$(document).delegate(selector, events, data, handler); // jQuery 1.4.3+

$(document).on(events, selector, data, handler); // jQuery 1.7+

Please refer to the link below http://api.jquery.com/live/

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.