NiceAdmin and bootstrap-switch.js style issue - Fixed - No Style applied to switch

I have been Googling for a couple of days to find a solution to this issue. The NiceAdmin demo clearly show the BootStrapSwitch having styles applied, but using the same code and styles, it is not working on our server.
Only I go this instead of the switch:



I checked many solutions that are shown, but none of them worked. The error in JS is as below:

TypeError: $(...).bootstrapSwitch is not a function
$('.switch')['bootstrapSwitch']();







I thought of getting my hands dirty to fix this issue.
On checking the JS files for some time I found that the function was not accepting the $ (even though I didn't get into debugging too much)

The function in the bootstrap-switch.js was as below:

$(function () {
  $('.switch')['bootstrapSwitch']();
});

I tried changing the function so it looks like this:

$(function ($) {
  $('.switch')['bootstrapSwitch']();
});

Now, when I checked the page, I can see the switch coming correctly and without any JS errors.

Of course, you need to include the jQuery file before the bootstrapswitch.js

Comments

Popular posts from this blog

Hide notification content in Android lock screen for Messages, email, whatsapp and selected apps.

Array functions in JavaScript