Hi,
I want to dynamically change select options but i can not.
How can i do, please check my code and help me.
thanks
var attributeoptions = [{
key: ‘icon’,
name: ‘icon’
},
{
key: ‘title’,
name: ‘title’
},
{
key: ‘description’,
name: ‘description’
},
{
key: ‘link’,
name: ‘link’
},
{
key: ‘target’,
name: ‘target’
},
{
key: ‘id’,
name: ‘id’
},
{
key: ‘class’,
name: ‘class’
},
{
key: ‘style’,
name: ‘style’
},
];
var shortcodestartx = new PgComponentType(‘zh.shortcodestartx’, ‘Shortcode STARTx’);
shortcodestartx.selector = ‘*’;
shortcodestartx.parent_selector = ‘body’;
shortcodestartx.tags = ‘major’;
shortcodestartx.sections = {
‘zh.shortcodestartx’: {
name: ‘SHORTCODE OPTIONSx’,
fields: {
‘zh.shortcodestartx.funcnamex’: {
type: ‘select’,
action: ‘apply_css’,
name: ‘Namex’,
live_update: true,
options: function (xyz, pgel) {
var xparent = pgel.closest(‘code.shortcode’);
if (xparent.tagName != 'code') {
return attributeoptions;
} else {
/*
array('icon' => '','title' => '','description' => '','link' => '','target' => '','id' => '','class' => '','style' => ''),
*/
var x = xparent.html().split('array(');
var x1 = x[1].split('),')[0];
var xmatch = (x1.replace(/\s/g, '')).split(" ").join("").split("'").join("").split(",").join("").split("=>");
console.warn(xmatch);
var result = [];
for (var i = 0; i < xmatch.length - 1; i++) {
result.push({
key: xmatch[i] + "-test",
name: xmatch[i] + "-test"
});
}
return result;
}
},
name: 'Attributes',
get_value: function (pgel) {
return 'title --not implement yet';
}
},
set_value: function (pgel, value, values, oldValue, eventType) {
return 'title -- not implement yet';
}
}
}
};
f.addComponentType(shortcodestartx);