使JEditable在新元素上工作(.live) [英] Making JEditable work on new elements (.live)

查看:84
本文介绍了使JEditable在新元素上工作(.live)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JEditable插件进行就地编辑.

I'm using the JEditable plugin for in-place editing.

我有一个设置"功能,该功能在所有相关类上调用.editable().问题是,我有新添加的元素,我也想使其可编辑.显然,.editable()是新添加的,因此永不被调用.

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.

换句话说,我希望获得jquery的live()函数的作用,但要实现editable()函数的作用.

In other words, I'm looking to get the effect that jquery's live() function does, but for the editable() function.

我当前的解决方法对我来说似乎很丑陋(redscribe_button是需要单击以编辑文本的按钮):

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');
});

换句话说,每次单击编辑按钮时,我只是打电话给.editable.

In other words, I'm just calling .editable every time the edit button is clicked.

有更好的解决方案的想法吗?

Any ideas for a better solution?

推荐答案

在一个元素上多次调用可编辑项不会产生不利的副作用,对吗?那么,为什么不每次发生任何更改时都重新进行设置.

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.

这篇关于使JEditable在新元素上工作(.live)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆