开发者

Edit links in place

I use this javascript to edit text in place: http://josephscott.org/code/javascript/jquery-edit-in-place no开发者_StackOverflow中文版w 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?


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 ..


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
});


Return false from your event handler, or with jQuery use e.preventDefault() in the handler, where e is the event object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜