JQuery JEditable - How to Disable on click editing

I was wondering if you can stop text being editable on click? I have a separate edit button to make the text editable and that's the only way that I want the user to be able to edit the text, so want to turn off the on click editing?

Any ideas?

Answers:

Answer

Britt is right, add a custom event, and trigger it with a button for example. Here is some code to explain it:

The custom event:

$('#id').editable('http://www.example.com/save.php', {
    event : 'custom_event'
});

And the trigger:

<button onclick="$('#id').trigger('custom_event');">click to trigger</button>
Answer

There's an undocumented option event that you can use when you create your jEditable fields.

(It's not actually undocumented but it's just mentioned off-hand in one sentence on the jEditable docs page.)

You can use it to change the event that makes the field editable. You can use any jquery event, even custom events.

For example, on my project I created an edit.mode event that makes the field editable which I can then trigger however I like, with a button, a hotkey, whatever.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.