admin管理员组文章数量:1389796
I'm using the JEditable plugin for in-place editing.
I have a "setup" function which calls .editable()
on all the relevant classes. The problem is, I have newly appended elements which I'd like to make editable as well. Obviously, being newly added, .editable()
never gets called on them.
In other words, I'm looking to get the effect that jquery's live()
function does, but for the editable()
function.
My current workaround seems kinda ugly to me (redscribe_button
is the button that needs to be clicked to edit the text):
$(".redescribe_button").live("click", function(click_event) {
click_event.preventDefault();
$(".editable", $(this).parent().parent()).editable("/temp/", {
event: "make_editable",
indicator : 'Saving...',
tooltip : 'Click to edit...'
});
$(".editable", $(this).parent().parent()).trigger('make_editable');
});
In other words, I'm just calling .editable every time the edit button is clicked.
Any ideas for a better solution?
I'm using the JEditable plugin for in-place editing.
I have a "setup" function which calls .editable()
on all the relevant classes. The problem is, I have newly appended elements which I'd like to make editable as well. Obviously, being newly added, .editable()
never gets called on them.
In other words, I'm looking to get the effect that jquery's live()
function does, but for the editable()
function.
My current workaround seems kinda ugly to me (redscribe_button
is the button that needs to be clicked to edit the text):
$(".redescribe_button").live("click", function(click_event) {
click_event.preventDefault();
$(".editable", $(this).parent().parent()).editable("/temp/", {
event: "make_editable",
indicator : 'Saving...',
tooltip : 'Click to edit...'
});
$(".editable", $(this).parent().parent()).trigger('make_editable');
});
In other words, I'm just calling .editable every time the edit button is clicked.
Any ideas for a better solution?
Share Improve this question asked Nov 10, 2010 at 11:19 Edan MaorEdan Maor 10.1k17 gold badges67 silver badges94 bronze badges2 Answers
Reset to default 5I just came to this question as well and solved it in a more elegant way (IMHO).
$('.jqEdit').live('click',function(event) {
event.preventDefault();
$(this).editable('save.php')
});
Calling editable more than once on an element has no adverse side effects, right? So why not just re-do the setup each time anything changes.
本文标签: javascriptMaking JEditable work on new elements (live)Stack Overflow
版权声明:本文标题:javascript - Making JEditable work on new elements (.live) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744711143a2621135.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论