This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,10 @@ angular.module('ui.bootstrap.buttons', [])
64
64
65
65
//ui->model
66
66
element . bind ( buttonsCtrl . toggleEvent , function ( ) {
67
+ if ( 'disabled' in attrs ) {
68
+ return ;
69
+ }
70
+
67
71
scope . $apply ( function ( ) {
68
72
ngModelCtrl . $setViewValue ( element . hasClass ( buttonsCtrl . activeClass ) ? getFalseValue ( ) : getTrueValue ( ) ) ;
69
73
ngModelCtrl . $render ( ) ;
Original file line number Diff line number Diff line change @@ -81,6 +81,23 @@ describe('buttons', function () {
81
81
expect ( $scope . model ) . toEqual ( 2 ) ;
82
82
} ) ;
83
83
84
+ it ( 'should not toggle when disabled - issue 4013' , function ( ) {
85
+ $scope . model = 1 ;
86
+ $scope . falseVal = 0 ;
87
+ var btn = compileButton ( '<button disabled ng-model="model" btn-checkbox btn-checkbox-true="falseVal">click</button>' , $scope ) ;
88
+
89
+ expect ( btn ) . not . toHaveClass ( 'active' ) ;
90
+ expect ( $scope . model ) . toEqual ( 1 ) ;
91
+
92
+ btn . click ( ) ;
93
+
94
+ expect ( btn ) . not . toHaveClass ( 'active' ) ;
95
+
96
+ $scope . $digest ( ) ;
97
+
98
+ expect ( btn ) . not . toHaveClass ( 'active' ) ;
99
+ } ) ;
100
+
84
101
describe ( 'setting buttonConfig' , function ( ) {
85
102
var originalActiveClass , originalToggleEvent ;
86
103
You can’t perform that action at this time.
0 commit comments