Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Object [object Object] has no method 'live'

Getting this error:

Uncaught TypeError: Object [object Object] has no method 'live'

From this JavaScript and jQuery code:

init: function(options) {
  var form = this;
  if (!form.data('jqv') || form.data('jqv') == null ) {
    options = methods._saveOptions(form, options);
    // bind all formError elements to close on click
    $(".formError").live("click", function() {

      //Getting error here:
      //Uncaught TypeError: Object [object Object] has no method 'live'

    });
  }
  return this;
};

Why is method live missing?

like image 455
Francesca Avatar asked Apr 25 '13 14:04

Francesca


3 Answers

.live was removed in jquery 1.9

See DOCs: http://api.jquery.com/live/


Try using .on instead:

$(document).on('click', '.formError', function(){ 
   //your event function
});
like image 175
Naftali Avatar answered Oct 18 '22 21:10

Naftali


According to the documentation, .live() has been deprecated since 1.7 and removed in 1.9.

You would either have to downgrade jQuery or use a newer version of the validation plugin, if it's available.

like image 7
Ja͢ck Avatar answered Oct 18 '22 22:10

Ja͢ck


.live() removed

The .live() method has been deprecated since jQuery 1.7 and has been removed in 1.9. We recommend upgrading code to use the .on() method instead.

To exactly match

    $("a.foo").live("click", fn)

You should write

    $(document).on("click", "a.foo", fn).

For more information, see the .on() documentation. In the meantime, the jQuery Migrate plugin can be additionally used to restore the .live() functionality.

like image 4
Richard P. Avatar answered Oct 18 '22 22:10

Richard P.