我需要添加 ajquery
contextMenu
以便jHtmlArea
它可以将关键字添加到 中jHtmlArea
,但是我很难将iframe
标签传递给contextMenu
触发器。
这里的代码
$(function () {
$.contextMenu({
selector: 'iframe body',
className: 'data-title',
callback: function (key, options) {
//inserts the keyword selected
insertAtCaret($(this).attr('id'), '{' + key + '}');
},
items: {
"TestPath": { name: "Test path", icon: "" },
...
}
});
//adding an extra button to the jHtmlArea
jHtmlArea.defaultOptions.toolbar.push([
{
// This is how to add a completely custom Toolbar Button
css: "keywords",
text: "Insert keywords",
action: function (btn) {
this.contextMenu(); //Error:this.contextMenu is not a function
}
}
]);
//just for context...
function insertAtCaret(areaId, text) {
...
}
//setting up `jHtmlArea` for input #editor
$('#editor').htmlarea();
});
单击自定义工具栏按钮时,我尝试了多种方法来获取“iframe body”元素,但均未成功。此外,我尝试将contextMenu
创建移动到 jHtml 加载事件内部,跳跃的问题是iframe
文档准备好后的加载。
其他可行的方法是简单地为上下文菜单指定选择器“iframe”,然后当用户在框架内右键单击时菜单应该弹出。
我需要一些指导方针或不同的方法。