I'm trying to use this script in dynamic created checkboxes.
If I only activate the checkboxes width the call $(':checkbox').checkboxpicker(); the checkboxes don't work. I need to call the function every time I insert a new checkbox. This fix the problem, but now the checkboxes that already exist are duplicated.
Did this to solve the problem.
var Checkboxpicker = function(element, options) {
this.element = element;
/** My fix **/
if (!$(element).is(':visible')){return;}
/** end **/
this.$element = $(element).hide();
this.options = $.extend({}, $.fn.checkboxpicker.defaults, options, this.$element.data());
// .btn-group-justified works with <label> elements as the <button> doesn't pick up the styles
this.$buttons = $('<label></label><label></label>').addClass('btn').click(this.clicked.bind(this));
this.$off = this.$buttons.eq(0).html(this.options.offLabel);
this.$on = this.$buttons.eq(1).html(this.options.onLabel);
this.$group = $('<div class="btn-group"></div>')
.append(this.$buttons)
.keydown(this.keydown.bind(this))
.insertAfter(element);
this.init();
};
I'm trying to use this script in dynamic created checkboxes. If I only activate the checkboxes width the call $(':checkbox').checkboxpicker(); the checkboxes don't work. I need to call the function every time I insert a new checkbox. This fix the problem, but now the checkboxes that already exist are duplicated.
Did this to solve the problem.
var Checkboxpicker = function(element, options) { this.element = element;