开发者

jeditable - multiple editable fields, trigger the right one to edit

开发者 https://www.devze.com 2023-02-15 09:36 出处:网络
Im using the jeditable jquery plugin. i have multiple separate ediatable areas, so when an edit button is clicked i want the relevant editable area to be in edit mode.

Im using the jeditable jquery plugin.

i have multiple separate ediatable areas, so when an edit button is clicked i want the relevant editable area to be in edit mode.

Im currently doing something crazy like this:

$(".edit_trigger").bind("click", function () {

            $(this).parent().parent().prev().prev开发者_开发问答().prev().trigger("edit");
        });

what is the better way to do this? as it keeps breaking as i change the layout.


Assuming .edit_trigger is a button you can include a ref="ID OF EDIT ELEMENT" on the button than change your code to.

$(".edit_trigger").bind("click", function () {

        $('#' + $(this).attr("ref")).trigger("edit");
    });
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号