[英]Calling Editinplace jquery plugin on a function and not on click
I am using jQuery editinPlace plugin, the default way of doing edit in place is using a click event on a selector, but the way I am trying to do is through context menu which calls a function "rename();".我正在使用 jQuery editinPlace 插件,进行就地编辑的默认方式是使用选择器上的单击事件,但我尝试执行的方式是通过上下文菜单调用 function“rename();”。 So how do I block the inline edit on click event.
那么如何阻止点击事件的内联编辑。 Please share some idea on how to do this...
请分享一些关于如何做到这一点的想法......
$('.context').editInPlace({
callback: function(idOfEditor) {
var renameUrl = "http://www.google.com/"+tablerowId+"/"+enteredText+"";
return enteredText;
}
});
Open the /jquery.editinplace.js source file.打开 /jquery.editinplace.js 源文件。 (Online version > http://code.google.com/p/jquery-in-place-editor/source/browse/trunk/lib/jquery.editinplace.js )
(在线版> http://code.google.com/p/jquery-in-place-editor/source/browse/trunk/lib/jquery.editinplace.js )
In the first function declaration $.fn.editInPlace
Line#26, change the following line:在第一个 function 声明
$.fn.editInPlace
Line#26 中,更改以下行:
new InlineEditor(settings, dom).init();
into >进入 >
dom.theEditor = new InlineEditor(settings, dom);
dom.theEditor.init();
dom.data("theEditor", dom.theEditor);
Now inside the click event of your context menu function, call this >现在在上下文菜单 function 的点击事件中,调用它 >
$("#myContextMenuElement").live("click", function (e) {
//your other code
rename(e); //you need to pass the event argument to it now
});
make sure the pass the 'e' into it.确保将“e”传递给它。
and in the rename function >并在重命名 function >
function rename(e) {
$("#myElementToEditInPlace").data("theEditor").openEditor(e);
}
works like a charm !奇迹般有效 !
EDIT:编辑:
To ensure that you don't allow user to active editor by clicking on the para itself > use this code:为确保您不允许用户通过单击 para 本身来激活编辑器 > 使用此代码:
var myDelegate = {
shouldOpenEditInPlace: function (a, b, c) {
if (c.target.id != "idOfYourContextElement") { //if the edit was not invoked through the context menu option
return false; //cancel the editor open event
}
return true;
}
};
and add the delegates in your initialization>并在您的初始化中添加代表>
$('.context').editInPlace({
callback: function(idOfEditor) {
var renameUrl = "http://www.google.com/"+tablerowId+"/"+enteredText+"";
return enteredText;
},
delegate: del
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.