akveo / blur-admin

AngularJS Bootstrap Admin Panel Framework
http://akveo.github.io/blur-admin/
Other
11.37k stars 3.1k forks source link

Switch Bootstrap #184

Open vitalibr opened 7 years ago

vitalibr commented 7 years ago

The directive Switch creates the bootstrap switch once the page is loaded.

But if you try to change the switch ngModel after loading the DOM, the button state (on or off) is not changed. (E.g. Loading server data).

It is necessary to load the plugin again? like this:

var input = $(elem).find('input');
input.bootstrapSwitch({
    size: 'small',
    onColor: attr.color
});
majkelo commented 7 years ago

I was struggling with the same issue. The solution was simple: do not use this directive. Instead use: https://github.com/JumpLink/angular-toggle-switch (especially check out it's is-disabled atribute, which will work when ngModel has changed. Alternative solution does not have this feature: https://github.com/frapontillo/angular-bootstrap-switch/issues/96)

vitalibr commented 7 years ago

nice @majkelo !

Look my PR :) simple and solved the issue

https://github.com/akveo/blur-admin/pull/187/commits/1c8bb71c55d227fb92428a90d3c6119e8a7f39b1

ThoughtZer commented 6 years ago

@vitalibr nice, I have already used it(your pr),and solved the problem