someone44
someone44

Reputation: 59

jQuery.autocomplete gives TypeError in Firefox

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?

Upvotes: 2

Views: 3069

Answers (1)

Kapil gopinath
Kapil gopinath

Reputation: 1053

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/

Upvotes: 4

Related Questions