EasyUI Forum
June 24, 2024, 10:59:11 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to remove an icon put with SetIcon  (Read 8235 times)
forum6691
Newbie
*
Posts: 39


View Profile
« on: March 08, 2014, 11:54:21 AM »

Hello

For my menu , to show which "mode " is on, I put an icon-ok .

J('#menu1').menu('setIcon', {target: J('#mn11')[0],iconCls: 'icon-ok'});

When I select an other menu, I want to remove this icon-ok. I have used
      J('#menu1').menu('setIcon', {target: J('#mn11')[0],iconCls: null});
or       J('#menu1').menu('setIcon', {target: J('#mn11')[0],iconCls: ''});

This is OK only for the first time. If I put again an icon-ok, then remove the icon, the icon-ok stay displayed ?
If I try with an other icon  'icon-remove' for example, after two changes, I have the two icons displayed in the same place !

So  how to delete an icon of a menu ?
Thanks
Cyril
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: March 08, 2014, 07:01:16 PM »

Please try to override the 'setIcon' method as:
Code:
<script>
$.extend($.fn.menu.methods, {
setIcon: function(jq, param){
return jq.each(function(){
$(param.target).children('div.menu-icon').remove();
if (param.iconCls){
$('<div class="menu-icon"></div>').addClass(param.iconCls).appendTo(param.target);
}
});
}
});
</script>
Logged
forum6691
Newbie
*
Posts: 39


View Profile
« Reply #2 on: March 09, 2014, 01:36:03 AM »

Stworthy.
Thanks for your answer, but I'm not a specialist of javascript.
I have some difficulties how to use your code.

For me the documentation of menu setIcon gives:
$('#mm').menu('setIcon', {
   target: $('#m-open')[0],
   iconCls: 'icon-closed'
});

In setIcon there are 2 parameters: the target menu and the iconCls that gives the bitmap. I understand this syntax.

If I add your code to override the setIcon methode, how I use it (syntax of calling ?) to delete the icon affected to one specific menu ?

Please give me an example of calling method.
Cyril
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: March 09, 2014, 03:33:53 AM »

Please refer to this example http://jsfiddle.net/n4bJR/.
Logged
forum6691
Newbie
*
Posts: 39


View Profile
« Reply #4 on: March 09, 2014, 08:40:15 AM »

OK, I have just to had your override in my script. I test it and it's OK.

Thank you very much Stworthy.  Wink
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!