JQuery JEditable - How to Add A Visible Edit Me Button?

Sam3k picture Sam3k · Jan 5, 2010 · Viewed 7.8k times · Source

i love this plugin but the reality is that most people won't realize at first that they can click on the text to edit.

Ideally, it would be nice to add a Button next to the text or a simple [Edit] link that the user clearly sees but never gets submitted via ajax.

Any ideas?

Answer

Tatu Ulmanen picture Tatu Ulmanen · Jan 5, 2010

Just add a event to the button which clicks on the jEditable field:

<span class="jeditable">jEditable field</span>
<input type="button" class="jeditable-activate" value="Edit me!" />

And in jQuery:

$('.jeditable-activate').click(function() {
    $(this).prev().click();
});

That should do it. After all, that's the same thing as the user clicking on the element.