I know that the ability to remove items from a menu dynamically after the menu is loaded is on the feature request list, and that the hide a menu item will not work for me.
I don't suppose anyone knows which array I could nuke (length=0?) to remove all of the items from a menu? I could then add items back in using the insertitem dynamically as I need them. I was trying to modify the insertitems script, but quickly found that I was over my head. Basically, I'd love a similar script that would allow me to call menuname.nuke() and it would remove all items from that particular menu array. I could then use the excellent insertitem to repopulate it. (Never would it remain empty).
Any ideas?
			
			
									
						
										
						Delete everything from menuitem array
Here is a beta of a function that will remove a menu item from an already built menu:
I'm now working on the insertItem funciton - Could have sworn I'd already written this but cannot seemto find a reference to it anywhere. Please let me know where it is if you can find it.
Cheers
Andy
Syntax is mm_deleteItem('MENUNAME', ITEMNUMBER)
ie, mm_deleteItem('Main Menu', 3) will delete the third item in the main menu
-- Andy
			
			
									
						
										
						I'm now working on the insertItem funciton - Could have sworn I'd already written this but cannot seemto find a reference to it anywhere. Please let me know where it is if you can find it.
Cheers
Andy
Code: Select all
function mm_deleteItem(_mN, _iN) 
{
	_mnu=getMenuByName(_mN)
	_ii=_m[_mnu][0][_iN-1]
	_tA=_nA()
	for(_r=0;_r<_mi.length;_r++)
	{
		if(_r!=_ii)_tA[_tA.length]=_mi[_r]
	}
	_mi=_tA
	_tA=_nA()
	
	_cnt=0;
	for(_r=0;_r<_m[_mnu][0].length;_r++)
	{	
		if(_m[_mnu][0][_r]!=_ii)
		{
			_tA[_tA.length]=_m[_mnu][0][_cnt]
			_cnt++
		}
	}
	_m[_mnu][0]=_tA	
	
	
	for(_r=_mnu+1;_r<_m.length;_r++)
	{
		for(_p=0;_p<_m[_r][0].length;_p++)
		{
			_m[_r][0][_p]--
		}
	}
		
	for(_r=0;_r<_m.length;_r++)
	{
		_m[_r][23]=0
		_gm=gmobj("menu"+_r)	
		if(_m[_r][7])
		{
			_gm.innerHTML=_drawMenu(_r)
		}
		else
		{
			_gm.innerHTML=""
			_fixMenu(_mnu)
		}
	}
}ie, mm_deleteItem('Main Menu', 3) will delete the third item in the main menu
-- Andy
Just developed a module for editing menu items, it's at 
http://milonic.com/mm_menueditapi.js
Hope this helps
Andy
			
			
									
						
										
						http://milonic.com/mm_menueditapi.js
Hope this helps
Andy
- 
				Streetwise
 - Advanced

 - Posts: 15
 - Joined: Mon Jan 10, 2005 1:14 pm
 
Thanks so much, but...
I really appreciate you sharing the remove script and I have several areas I can immediately use it!
However, I was wondering if there was an easy way to accomplish my original task of erasing all of the items from a particular menu. Or, alternately I could use the remove script your provided if there was a way to query how many items there were in a particular menu (the length of the appropriate array?)
Thanks for your help!
			
			
									
						
										
						However, I was wondering if there was an easy way to accomplish my original task of erasing all of the items from a particular menu. Or, alternately I could use the remove script your provided if there was a way to query how many items there were in a particular menu (the length of the appropriate array?)
Thanks for your help!
Re: Delete everything from menuitem array
Hi Andy
I tried to use mm_deleteItem () and other functions given in the mm_menueditapi.js mentioned above ...
but every time i get a JS error
object expected referencing to mmenudom.js
In my code i have also included milonic_src.js
Sunny
			
			
									
						
										
						I tried to use mm_deleteItem () and other functions given in the mm_menueditapi.js mentioned above ...
but every time i get a JS error
object expected referencing to mmenudom.js
In my code i have also included milonic_src.js
Sunny

