mdbootstrap / bootstrap-toggle-buttons

Bootstrap-toggle-buttons has moved to https://github.com/nostalgiaz/bootstrap-switch
https://github.com/nostalgiaz/bootstrap-switch
Apache License 2.0
1.02k stars 92 forks source link

Icon in toggle button #49

Open cmbankester opened 11 years ago

cmbankester commented 11 years ago

Is it possible to put an icon in a toggle button, something like:

$('#toggle-me').toggleButtons({
  label: {
    enabled: $("<i class='something'></i>"),
    disabled: $("<i class='something-else'></i>")
  }
});

The motivation here is font-awesome icons inside a toggle button. Any ideas?

SuggeElson commented 11 years ago

Replace in js file line 50 and 51 with:

$spanLeft = $('').addClass("labelLeft").append(options.label.enabled === undefined ? "ON" : options.label.enabled); $spanRight = $('').addClass("labelRight").append(options.label.disabled === undefined ? "OFF " : options.label.disabled);

basic i change text method to append, also you need to put in your css fix for icons where icon16 is my icon class. .toggle-button .icon16 {float: none;}