I'm using jEditable, which turns my div into a nice little form complete wit开发者_如何学Pythonh textarea, Cancel and Submit buttons on-the-fly.
After jEditable creates the textarea is created and adds it to the DOM, I'd like to attach the elastic plugin to the element (so the textbox expands and shrinks nicely).
I'm currently using $.live() - which waits for the user to click on the form, THEN attaches the elastic plugin.
It would be cool if I could attach elastic right after the element is created - without messing around with plugin code - is that possible?
Don't use .live()
. Instead, after you have initialized the jEditable plugin just chain it with a click event handler
$(function() {
$('.edit').editable(
'http://www.example.com/save.php',
{
type : 'textarea',
cancel : 'Cancel',
submit : 'OK',
tooltip : 'Click to edit'
}
)
.click(function() {
$(".edit textarea").elastic();
});
});
Try the fiddle
http://jsfiddle.net/Kkg2b/1/
精彩评论