0

I am trying to develop a wordpress plugin and for it I need to add tinymce listbox with dynamic values. At the moment I have stored dynamic objects in listv array and I need to push them in to tinyMCE.activeEditor.settings.myKeyValueList. But it wont work. even I have tried push and valueOf javascript methods but still no luck.

function getValues() {
    //Set new values to myKeyValueList 
    var listv = [];
    var len = pw_script_vars.ad;
    for (i = 0; i < len.length; i++) {
        listv[i] = {
            text: pw_script_vars.ad[i],
            value: pw_script_vars.ad[i]
        };
    }
    for (i = 0; i < listv.length; i++) {
        tinyMCE.activeEditor.settings.myKeyValueList += [listv[i]];
    }

    return tinyMCE.activeEditor.settings.myKeyValueList;
}
3

1 Answer 1

3

From what I have seen by searching for tinyMCE myKeyValueList, it seems like you have to simply assign the value

tinyMCE.activeEditor.settings.myKeyValueList = listv;

instead of trying to add to it:

for (i = 0; i < listv.length; i++) {
    tinyMCE.activeEditor.settings.myKeyValueList += [listv[i]];
}

If you want to append to the existing myKeyValueList array (if it actually exists), see How to extend an existing JavaScript array with another array, without creating a new array? .

Sign up to request clarification or add additional context in comments.

1 Comment

thanx mate it works.. i was trying to fix this for almost 5 hours.. thank you you saved my day...!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.