javascript - No method live error with jQuery 1.9.1 -


the following code worked fine jquery 1.7.2. doesn't jquery 1.9.1. gives error "uncaught typeerror. object [object object] has no method 'live'.

how can fix problem?

thanks in advance.

enter image description here

<script> $(document).ready(function(){      var tablecont = $("#tablesorter1");     var module = "category";      function updateitem()     {             $.ajax({             type: "post",              url: "http://localhost/tangen2014/index.php/category/admin/ajaxgetupdate",              complete: function(data)             {                 tablecont.html(data.responsetext);             }         });     }          //on submit event     $(".changestatus").live('click', function(event){         event.preventdefault();         var href = $(this).attr("href");         var id =href.substring(href.lastindexof("/") + 1);         $.ajax({             type: "post",              url: "http://localhost/tangen2014/index.php/kaimonokago/admin/changestatus"+"/"+module+"/"+id,             complete: function()             {                 updateitem();             }         });       }); }); </script> 

from upgrade guide

the .live() method has been deprecated since jquery 1.7 , has been removed in 1.9. recommend upgrading code use .on() method instead

so need use .on() here:

$('#tablesorter').on('click', ".changestatus", function(event){     // code here }); 

it's better delegate events closest static parent instead of document level better performance.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -