Tuesday, April 17, 2012

An update to the jquery live() function post from before

This isn't a big update.

Just a note.  In a previous post (http://coderambled.blogspot.com.au/2012/03/jquery-coffeescript-and-javascript-html.html) I talked about how my form wasn't answering to click events and whatnot if it was populated using ajax type loading and the answer was the .live function.

Turns out this is deprecated, better to use .on


$(document).on('click', '#form_submit', function() {

    $("#animation").html("<img src='/images/ajax-loader.gif' />");

});


That is my preferred way to do it.  No coffeescript this time because I'm editing a rails 3.0 project.

Also I learned that each release of jquery_ui has a list of where it's hosted on content delivery networks.

http://stackoverflow.com/questions/4944293/jquery-liveclick-vs-click has some good code snippets on the subject

No comments:

Post a Comment