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");
});
精彩评论