Hello,
I coded a plugin to insert an internal link, that is, a link to a resource on the website.
The plugin works fine, up to the point where it wants to enclose, the text selected by the user, by a link <a > tag in the okListener handler.
Here is my handler:
The first alert is displayed, but not the second one.
The linkUrl, target and selection variables are retrieved fine.
The stumbling block is when I try to enclose the selected text, by an <a> tag.
Has any one tried to do this ?
Thanks !
I coded a plugin to insert an internal link, that is, a link to a resource on the website.
The plugin works fine, up to the point where it wants to enclose, the text selected by the user, by a link <a > tag in the okListener handler.
Here is my handler:
var okListener = function(event) { var linkUrl = this.getContentElement(linkTabName, 'selectedLink').getValue(); var target = this.getContentElement(linkTabName, 'selectedTarget').getValue(); // Get the element currently selected by the user var editor = this.getParentEditor(); var selection = editor.getSelection(); var attributes = {href : linkUrl, target : target}; alert("displayed"); selection.getNative().setAttributes(attributes); alert("not displayed"); parentEditor.dialog.getCurrent().removeListener("ok", okListener); };
The first alert is displayed, but not the second one.
The linkUrl, target and selection variables are retrieved fine.
The stumbling block is when I try to enclose the selected text, by an <a> tag.
Has any one tried to do this ?
Thanks !
Re: Insert an internal link
I use something similar to this :
Does that help?
Thanks,
Zanpakutō
Re: Insert an internal link
Spot on !
I tried it on Firefox on my Linux box and it worked just fine.
You can see it here:
http://www.thalasoft.com/engine/modules ... npageId=78
Now I need to see if it would work on IE8 as well.
Thanks !
Re: Insert an internal link
Hi Steph,
great to hear it works now.
I would expect the code to run fine in IE versions 6 or above, however, I don't even have a copy of IE being a Fedora Linux user myself. Strictly Opera, Firefox and Webkit for me.
Good luck with your project,
Zanpakutō