JQuery edit plugin that lets you trigger editing from another element
I am currently using Jeditable for in-place editing functionality. Jeditable has a few useful options, but (as far as I know) it prevents editing from being triggered other than clicking the appropriate element.
Ie let my element have id comment
. With Jeditable, the only way to start editing is to click comment
. I would like to add a little text next to comment
(for example, "Click to edit comment") that, when clicked, turns comment
into an editable text box (and customize the Save and Cancel buttons, etc.).
source to share
Okay, I hacked the case. In this blog post, the author writes
Now you can use any custom event to trigger Jeditable.
$(".editable").editable("http://www.example.com/save.php", { event : "make_editable" });
So I did this and then did:
$("#id-for-text").click(function() {
$("#comment").trigger('make_editable');
});
source to share
Based on your comments above, you can do this:
var editFn = (function(){ return $('#comment').click; })();
$('#id-for-text').click(editFn);
$('#comment').unbind('click');
This tells the label that the click event should match the click event and then unbinds the event in the comment.
Not sure if unbind will destroy the link to editFn, hence enable closure.
source to share