Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Switching Button icon using onClick event

$
0
0
Hello Kevin,

You can achieve this by dynamically adding/removing the k-i-pin and k-i-unpin classes e.g.
$("#button").kendoButton({
  icon: "pin",
  click: function (e) {
        $('.UserFavouritesPanel').animate({ width: 'toggle' }, 350);
        var icon = this.element.children(".k-icon");
        if ($('.UserFavouritesPanel').width()>1) {
            icon.removeClass("k-i-pin");
            icon.addClass("k-i-unpin");
        } else {
            icon.removeClass("k-i-unpin");
            icon.addClass("k-i-pin");
        }
    }
});
The problem will occur with the code that you provided because when initializing a new button, the previous icon class will not be removed. 

Regards,
Daniel
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items

Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>