jega
|
|
« on: September 02, 2021, 03:46:59 AM » |
|
Hi
Have this code to add dynamically menu items
<div id="menu_administration" class="easyui-menu"> <div id="adm1" data-options="iconCls:'icon-task_scheduler'"> <span>Scheduler</span> <div> <div data-options="iconCls:'icon-log'"> <span>Scheduler log</span> </div> </div> </div> </div>
Calling function getFilesListToMenu('scheduledlog','menu_administration','Scheduler log') to fill the span Scheduled log with all filenames in folder.
This works perfect.
function getFilesListToMenu(filePath,topMenu,subMenu){ $.ajax({ url: 'getsystemfromdb.asp?st=filelist&filepath='+filePath, type: 'get', cache:false, data: { }, success: function(data){ filesData = data[0].children; $.each(filesData, function(index, element){ var item = $('#'+topMenu).menu('findItem', subMenu); $('#'+topMenu).menu('appendItem', { parent: item.target, text: element.name, iconCls: element.iconCls, onclick: function(){ window.open(filePath+'/'+element.name+'?'+Date.now()) } }); }); } }); }
When there comes a new file in the scheduledlog folder i will call the function again, but before, all items must be removed.
Have tried several things with removeItem, but can't get it to work.
Any help ?? Maybe a new function with topMeny and subMenu parms that do the trick
Jesper
|