0
我想使用javascript動態地填充我的w2ui工具欄菜單項。我嘗試使用:document.getElementById
,但它沒有工作,因爲沒有下拉菜單的ID。w2ui工具欄 - 有沒有辦法動態地填充菜單項
的部分過程是,我試圖填補動態
ToolBarView.prototype.buildView = function(processController) {
$('#MDItoolbar').w2toolbar({
name: 'toolbar',
items: [
{ type: 'button', id: 'saveProcess' , name: 'saveProcess', caption: 'save Process', icon: 'fa-check', checked: true },
{ type: 'break', id: 'break0' },
{ type: 'button', id: 'NewProcess' , name: 'NewProcess', caption: 'New Process', icon: 'fa-check', checked: true },
{ type: 'break', id: 'break1' , name: 'break1' },
{ type: 'menu', id: 'processes', caption: 'Drop Down', img: 'icon-folder',
name:'processes',
items: [
{ text: 'Item 1', img: 'icon-page' },
{ text: 'Item 2', img: 'icon-page' },
{ text: 'Item 3', img: 'icon-page' }
]
},
{ type: 'break', id: 'break3' ,name:'break3'},
{ type: 'spacer',name:'spacer' }
]
});
w2ui.toolbar.on('*', function (event) {
console.log('EVENT: '+ event.type + ' TARGET: '+ event.target, event);
if (event.target =='saveProcess')
{
var saveProcess = new SaveProcessView("save the process",processController);
}
if (event.target =='NewProcess')
{
processController.NewProcess();
}
});
};