Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2006-10-03 07:24:36

juo
New member
Registered: 2006-10-03
Posts: 3

InsertWords plugin: dynamically setting the dropdown list

Hi,

This might seem a bit of a wacky thing to want to do, but basically I want to be able to change the values in the dropdown in the InsertWords plugin, depending upon certain user selections. It goes back to the server and refreshes the page after the User makes the selection, so I'm even trying to recreate the HTMLArea object with the new object array. For some reason, it doesn't work though.

Anyone have any suggestions as to the best way to do this? Do I need to get recreating the HTMLArea working, or can I simply replace the existing dropdown on the fly?

Thanks if you can help, I would greatly appreciate it. Great app, btw, we really like using it. I get jaws on the floor every time I demo it wink

Thanks,
Juo

Last edited by juo (2006-10-03 07:25:47)

Offline

#2 2006-10-17 05:21:58

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: InsertWords plugin: dynamically setting the dropdown list

Hi juo,
add this function to insert-words.js

InsertWords.prototype.newValues = function (id,newValues) {
    var elem = this.editor._toolbarObjects[id].element;
    while (elem.length > 1)
    {
        elem.options[1] = null;
    }
    for (var i in newValues)
    {
        var opt = new Option(i,newValues[i]);
        elem[elem.length] = opt;
    }
}

Call it for example by something like this:

<a href="javascript:void(0);" onclick="xinha_editors.myTextArea.plugins.InsertWords.instance.newValues('IW-id0',{option1:'text1',option2:'text2'});">New Options</a>

xinha_editors.myTextArea (replace myTextArea with your editor id) is the editor object, supposed you use the xinha_editors array.
The first parameter is the internal id of the dropdown. If you have more than one, change the number.

Last edited by ray (2006-10-17 05:22:48)

Offline

#3 2006-10-17 13:20:47

juo
New member
Registered: 2006-10-03
Posts: 3

Re: InsertWords plugin: dynamically setting the dropdown list

Hi ray,

That worked perfectly, its the exact solution I was looking for! Thanks a million, youre a star smile

(well, it works nearly perfectly, for some reason it doesn't work when the editor is first loaded, but subsequent javascript actions cause it to work. Appears the editor isn't present until the page is fully loaded, so looks like I just need to invoke the javascript to set the dropdown at the very end or something. I should be able to figure that out).

Should this be added to the source of the plugin? If anyone wants me to do this, let me know. Should I create a ticket?

Thanks again, I'm in your debt.

Regards,
juo

Offline

Board footer

Powered by FluxBB