Reputation: 11308
I use this javascript to edit text in place: http://josephscott.org/code/javascript/jquery-edit-in-place now I need to edit links as well. But when I click on link instead of just making it editable I'm redirected to the link address. How can I change it so that if double click a link just make it editable and don't redirect anywhere?
Can anyone please help?
Upvotes: 1
Views: 406
Reputation: 196002
use the dblclick
event and the preventDefault
method
$('a_selector').eip( "save.php", {
form_type: "textarea"
} );
$('a_selector').dblclick(function(e){
e.preventDefault();
})
update After toying around with the plugin a little..
I believe it natively allows to set the event which starts the edit..
$('a').eip( 'save.php', {
form_type : 'textarea',
edit_event : 'dblclick'
} );
but i am not sure they correctly handle the case where the target element is a link, as i do not see in their code any attempt to stop the default behaviour ..
Maybe you could modify the source code and add it yourself ..
Upvotes: 3
Reputation: 1305
Return false from your event handler, or with jQuery use e.preventDefault()
in the handler, where e is the event object.
Upvotes: 0
Reputation: 7359
You'll need to override the default link behavior, then trigger the edit-in-place code.
$("a").click(function(){
//whatever you have to call to make it editable
return false; //prevent the link from being followed
});
Upvotes: 1