我目前使用jQuery插件插件來創建基於標題框的項目slu g。這很好。我有麻煩做的只是當用戶點擊編輯鏈接時更新slug。現在當編輯鏈接被調用時,slug函數被啓動並且工作正常,但是當點擊「完成」鏈接時,我需要找到一種方法來關閉slug函數。我希望這是有道理的。如何結束點擊jQuery的功能
$('#edit_slug').click(function() {
//allow user to edit the project slug
$("#edit_project_name").stringToSlug({ //this is the slug plugin
getPut: '.project_slug',
hide: false
});
$('input.project_slug').show(); //show the input
$('input.project_slug').next("span").remove().end(); //remove the span with the slug
$('#edit_slug').hide(); //hide edit link
$('input.project_slug').after(" <a href='#' id='done_edit_slug'>Done</a>"); //show done link
});
//if the user is done editing the slug show the span with the slug in it
$('#done_edit_slug').live('click', function() {
$("#edit_project_name").stringToSlug().end(); //my attempt to make the function end
$('input.project_slug').after("<strong><span>"+$('input.project_slug').val()+"</span></strong>"); //show the slug as a span
$('input.project_slug').hide(); //hide the input box
$('#done_edit_slug').remove().end(); //remove done link
$('#edit_slug').show(); //show edit link
});
我不確定這是實現這一目標的最佳方式,我願意接受創意。最主要的是我不確定如何在點擊#done_edit_slug
時結束stringToSlug()
函數。
謝謝!
return false; ? – delphist 2011-02-27 00:08:01