开发者

Customising CKEditors Link Plugin

开发者 https://www.devze.com 2023-02-27 04:26 出处:网络
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

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: li开发者_开发百科nkLang.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?


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.

0

精彩评论

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