tags:

views:

73

answers:

1

I got a JQuery UI button with an icon (locked) and I want it to switch to unlocked when I hover, I am pretty sure it's quite simple but after searching on Google I've found no doc/example about that. Here is my code

$("#frmClients button.btnConnexion").button({ icons: { primary: 'ui-icon-locked' }, text: true });

And here the documentation page of the UI http://jqueryui.com/demos/button

+1  A: 

This is just a stab, but from the documentation, something like this might work:

$("#frmClients button.btnConnexion")
  .button({ icons: { primary: 'ui-icon-locked' }, text: true })
  .hover(function() {
    $(this).button('option' , 'icons' , { primary: 'ui-icon-unlocked' });
  }, function() {
    $(this).button('option' , 'icons' , { primary: 'ui-icon-locked' });
  });
jmar777
Tried working arround that, didn't work.
Dominique
Hmm... any idea where it's failing? What happens if you throw in some alerts or console.logs inside the hover callbacks?
jmar777
Well I think this is not a valid syntax for jquery ui, this code doesn't say when to show locked and when to show unlocked, I suppose the button only show the last one specified (locked).
Dominique
Not sure why that's not working for you. I just ran that code snippet (with a different selector and without the first .button() call) over on the jQueryUI example page (http://jqueryui.com/demos/button/icons.html) and it worked perfectly.
jmar777
Haha, I've just copy/pasted the same code like I did yesterday...it works...guess it was an Error 17 (17inch in front of the monitor).Thanks +1
Dominique
Heh - glad it's working then. Thanks for the accept!
jmar777