-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsRadiobuttons.js
39 lines (32 loc) · 1.06 KB
/
csRadiobuttons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(function ($) {
$.widget("cs.radiobuttons", {
options: {
checkboxClass: '',
activeClass: 'active',
onChange: function (radio) {
}
},
_create: function () {
var widget = this,
element = this.element;
widget.checkboxes = element.find("." + widget.options.checkboxClass);
widget.checkboxes.click(function () {
var chkBox = $(this);
if (widget.active !== chkBox) {
widget.options.onChange(chkBox);
}
widget.checkboxes.removeClass(widget.options.activeClass);
chkBox.addClass(widget.options.activeClass);
widget.active = chkBox;
});
widget.checkboxes.first().click();
},
getActiveCheckbox: function () {
return this.active;
},
destroy: function () {
var widget = this;
widget.checkboxes.unbind();
}
});
})(jQuery);