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;
}
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? .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.