自定义 CKEditors 链接插件

发布于 2024-11-02 03:37:13 字数 1514 浏览 2 评论 0原文

我正在编辑链接插件,以允许工作人员选择内部内容的链接。 我已成功向链接插件对话框添加另一个选项卡,其中包含带有 onKeyup 事件的文本输入。这个想法是,当他们输入时,它会在下面列出结果,他们可以在其中选择他们想要的链接。选择后,我将使用 url 和协议更新信息选项卡。

这是现有链接插件中的代码部分:

....
....

//Should update info tab with value
function AddLink(txtLink)
{
    var dialog = this.getDialog();
    dialog.setValueOf('info', 'url', txtLink);
    dialog.setValueOf('info', 'protocol', ''); 
}

//called when the user types in the search box. currently just uses text for basic testing
var searchBoxChanged = function ()
{
    var dialog = this.getDialog();
    var href = $(this).attr('href');
    var txt = dialog.getValueOf('article', 'searchWords');
    $('#searchResults').html("<a href=\"JavaScript:AddLink('/Article/View/" + txt +      "')\">Test Title</a>");
}

....
....
{
     //Adds extra tab to the link plugin for custom link searching
     id: 'article',
     label: linkLang.article,
     title: linkLang.article,
     elements:
     [
         {
              type: 'text',
              id: 'searchWords',
              label: linkLang.articleSearch,
              style: 'height:40px',
              size: 29,
              onKeyUp: searchBoxChanged
          },
          {
              type: 'html',
              html: '<div id="searchResults">Please start tying to get results</div>'
          }
     ] 


}
....
....

目前我只是使用文本框中的一些基本静态数据。页面上创建的链接正常,但是单击它时出现错误:

CRIPT5009:“AddLink”未定义

任何人都可以阐明我哪里出错了吗?

I am editing the link plugin to allow staff to select links to internal content.
I have managed to add another tab to the link plugin dialog with a text input with an onKeyup event. The idea is, when they type it will list the results below where they can select the link they want. Once selected I was just going to update the info tab with the url and protocol.

Here is my code sections from the existing link plugin:

....
....

//Should update info tab with value
function AddLink(txtLink)
{
    var dialog = this.getDialog();
    dialog.setValueOf('info', 'url', txtLink);
    dialog.setValueOf('info', 'protocol', ''); 
}

//called when the user types in the search box. currently just uses text for basic testing
var searchBoxChanged = function ()
{
    var dialog = this.getDialog();
    var href = $(this).attr('href');
    var txt = dialog.getValueOf('article', 'searchWords');
    $('#searchResults').html("<a href=\"JavaScript:AddLink('/Article/View/" + txt +      "')\">Test Title</a>");
}

....
....
{
     //Adds extra tab to the link plugin for custom link searching
     id: 'article',
     label: linkLang.article,
     title: linkLang.article,
     elements:
     [
         {
              type: 'text',
              id: 'searchWords',
              label: linkLang.articleSearch,
              style: 'height:40px',
              size: 29,
              onKeyUp: searchBoxChanged
          },
          {
              type: 'html',
              html: '<div id="searchResults">Please start tying to get results</div>'
          }
     ] 


}
....
....

At the moment I am just using some basic static data from the textbox. The link in creating on the page ok, but when it is clicked I get the error:

CRIPT5009: 'AddLink' is undefined

Can anyone shed some light on where I am going wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拧巴小姐 2024-11-09 03:37:13

根据我的经验,[“x”未定义]错误通常意味着存在语法错误,或者通常是函数中的某些内容与您认为的不同。

可能 this.getDialog() 脱离了上下文,因此它不会返回任何内容。那么,dialog.setValueOf() 将不起作用。

In my experience, ["x" is undefined] errors quite often mean there's a syntax error or, often, something in the function does not evaluate to what you think it does.

Possibly, this.getDialog() is out of context so it doesn't return anything. Then, dialog.setValueOf() won't work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文