Hi everyone,
I'm currently working on extending the Link-dialog in CKeditor 3.0.2 and have stumbled on something I cannot seem to solve myself.
I have added a new option to the Linktype-select to be able to link to internal site-pages. I've got this to work using the following code to make up the Options-object:
This works like a charm HOWEVER when I try to add yet another option to link to internal news-pages using the below object:
Once I add this object the functionality breaks for both custom options. When I press OK to close the dialog, instead of creating the link it says that data.news is undefined when trying to save a link to a News-page and that data.page is undefined when saving a link to a page in the site.
Below is the code I have added to the Switch-statement in the onOk function:
However, if i comment out the setup and commit functions of one of the objects there is no problem.
I hope someone can help me out here because I'm stumped as to why this is happening and I really need this to work.
Thanks in advance,
Chris
I'm currently working on extending the Link-dialog in CKeditor 3.0.2 and have stumbled on something I cannot seem to solve myself.
I have added a new option to the Linktype-select to be able to link to internal site-pages. I've got this to work using the following code to make up the Options-object:
{
type : 'vbox',
id : 'pageOptions',
width : 260,
align : 'center',
padding : 0,
children :
[
{
type : 'select',
label : editor.lang.link.toSitePage,
items : sitePages,
setup : function( data )
{
if ( data.page )
this.setValue( data.page.url || '' );
},
commit : function( data )
{
if ( !data.page )
data.page = {};
data.page.url = this.getValue();
}
}
]
}This works like a charm HOWEVER when I try to add yet another option to link to internal news-pages using the below object:
{
type : 'vbox',
id : 'newsOptions',
width : 260,
align : 'center',
padding : 0,
children :
[
{
type : 'select',
label : editor.lang.link.toNewsPage,
items : newsPages,
setup : function( data )
{
if ( data.news )
this.setValue( data.news.url || '' );
},
commit : function( data )
{
if ( !data.news )
data.news = {};
data.news.url = this.getValue();
}
}
]
}Once I add this object the functionality breaks for both custom options. When I press OK to close the dialog, instead of creating the link it says that data.news is undefined when trying to save a link to a News-page and that data.page is undefined when saving a link to a page in the site.
Below is the code I have added to the Switch-statement in the onOk function:
case 'page': attributes._cke_saved_href = data.page.url; break; case 'news': attributes._cke_saved_href = data.news.url; break;
However, if i comment out the setup and commit functions of one of the objects there is no problem.
I hope someone can help me out here because I'm stumped as to why this is happening and I really need this to work.
Thanks in advance,
Chris

Re: Extending Link-dialog in CK-editor
The below object is missing an ID, once we added this everything worked fine.
{ type : 'select', label : editor.lang.link.toSitePage, items : sitePages, setup : function( data ) { if ( data.page ) this.setValue( data.page.url || '' ); }, commit : function( data ) { if ( !data.page ) data.page = {}; data.page.url = this.getValue(); } }