EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: forum6691 on March 08, 2014, 11:54:21 AM



Title: How to remove an icon put with SetIcon
Post by: forum6691 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


Title: Re: How to remove an icon put with SetIcon
Post by: stworthy 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>


Title: Re: How to remove an icon put with SetIcon
Post by: forum6691 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


Title: Re: How to remove an icon put with SetIcon
Post by: stworthy on March 09, 2014, 03:33:53 AM
Please refer to this example http://jsfiddle.net/n4bJR/.


Title: Re: How to remove an icon put with SetIcon
Post by: forum6691 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.  ;)