The following code snippet is returning an error in firebug:
Parameter is not an object” code: “1003
t.selectNode(s.$); ckeditor.js (line 11883)
My code is basically searching for elements of a certain type e.g input. I then want to make the current element of type selectElement as defined in the API here: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dom.selection.html#selectElement
var selectOption = dialog.getValueOf('find', 'findNext');
var documentWrapper = editor.document; // [object Object] ... CKEditor object
var documentNode = documentWrapper.$; // [object HTMLDocument] .... DOM object
elementArray = documentNode.getElementsByTagName(selectOption);
editor.getSelection().selectElement(elementArray[count]); // Trying to make the current element of type selectElement
var elementX = editor.getSelection().getSelectedElement();
alert('element ' + elementX.getName());
If I manually highlight an element in the WYSIWYG area then the last two lines of the above code snippet work, and getSelectedElement is defined in the same class as selectElement so I dont know why I’m getting the error.
Some difficulties:
getElementsByTagName creates a Node collection, not an array.
The Node collection is very limited as far as available methods and properties are concerned.
Here is a concise explanation of the important things to know about Node collections.
A collection is not an array
http://www.sitepoint.com/a-collection-is-not-an-array/
After running getElementsByTagName, I moved the collection into an array.
The elements were not in a usable format, so I also converted them into DOM elements.
Rather than working with an element selection, I used a range selection created from the element Node. I found ranges to be more flexible to work with.
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dom.range.html
Then at the end I created a DOM selection object containing the selected element. I created some sample objects using different methods that are available for a selection object.
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dom.selection.html
I saw your notes about the object types [object Object] and [object HTMLDocument].
Have you tried using ” console.log(); ” with FireBug? It shows you all the available methods and properties for each object. I added it for most of the objects in the included code. see what you think.
Look at the Console panel in FireBug to see the infomation about each object that log is run on. Try console.log( CKEDITOR ); to get a good overview of whats available.
Important Note: For Internet Explorer you need to open the Developer Tools window and activate Debugging in the Script panel while using ” console.log(); “. Otherwise it will throw an error.
Here’s the code:
Be Well,
Joe