JQuery JEditable - How to Disable on click editing
Asked Answered
T

2

8

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?

Troublesome answered 30/7, 2010 at 0:2 Comment(0)
B
4

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>
Baptistry answered 15/12, 2010 at 1:23 Comment(2)
That will prevent you to allow mouseover if you use event for custom-event ?Fazio
@Lutsen, really great solution. It took some time to understand your solution but after it, it's working like charm. I was seeking this answer since so many days (around 8 to 10 days). But then I prayed to Stackover Angel and finally I found this solution. I also thumbs up your solution.Annetteannex
P
2

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.

Pediform answered 13/8, 2010 at 19:30 Comment(3)
A am appreciating your answer too for great explanation which I couldn't understood while reviewing doc for jEditable.Annetteannex
I am a little confused as to what the 'event' value represents. Is it a function name?Highborn
Ignore the above question... it was stupid and I understand what it is now. Sorry... I asked before I thought... happens sometimes. There was something missing which was the unbinding part that I was interested in but found it later (sort of like a toggle).Highborn

© 2022 - 2024 — McMap. All rights reserved.