Hello,
I'm having hard times trying to add an element into editor from my custom widget.
Below is where it happens inside my widget:
data: function() { var sliderJS = '<script type="text/javascript">' + 'jQuery(document).ready(function() {' + ' jQuery(".bxslider").bxSlider({' + ' mode: "fade",' + ' captions: true' + ' });' + ' alert("dddd");' + '});' + '</script>'; var myscript = CKEDITOR.dom.element.createFromHtml(sliderJS, this.editor.document); this.editor.insertElement(myscript); },
After loading a snippet and clicking OK, everything works fine, but if I try to toggle "Source" mode on and off, I get the following error:
TypeError: this.editor.getSelection(...) is null
Could someone share some light please on what I'm doing wrong.
Or maybe someone could give me advice on what is the best way to add inline javascript into editor from a custom widget.
Any help much apprieciated,
Martin
How to add inline javascript from a custom widget ?
Hello,
Could somebody point me out what is the best way to add some inline javascript to editor content from a custom widget ?
For example, something like:
The above unfortunetaly doesn't work for me...
Any help much appreciated,
Martin
I think you have an extra
I think you have an extra argument- I would think that this would work fine.
Appears that the problem
Appears that the problem happens only when trying to insertElement on "this.element", which is the widget wrap element.
Works fine with other selected DOM elements, also inside the widget structure.