Use jQuery to attach behavior after a new element has been added to the DOM? -
i'm using jeditable, turns div nice little form complete textarea, cancel , submit buttons on-the-fly.
after jeditable creates textarea created , adds dom, i'd attach elastic plugin element (so textbox expands , shrinks nicely).
i'm using $.live() - waits user click on form, attaches elastic plugin.
it cool if attach elastic right after element created - without messing around plugin code - possible?
don't use .live()
. instead, after have initialized jeditable plugin chain click event handler
$(function() { $('.edit').editable( 'http://www.example.com/save.php', { type : 'textarea', cancel : 'cancel', submit : 'ok', tooltip : 'click edit' } ) .click(function() { $(".edit textarea").elastic(); }); });
try fiddle
http://jsfiddle.net/kkg2b/1/
Comments
Post a Comment