Sha256: f503ed63b8ba46a275bfdabbe0a5e1cc817ff9169e9a77da48519806a1cd4dad
Contents?: true
Size: 1.28 KB
Versions: 58
Compression:
Stored size: 1.28 KB
Contents
/** * Input view for boolean values. * * @param {boolean} [options.displayUncheckedIfDisabled=false] * Ignore the attribute value if the input is disabled and display * an unchecked check box. * * @see {@link module:pageflow/ui.pageflow.inputView pageflow.inputView} for further options * @class * @memberof module:pageflow/ui */ pageflow.CheckBoxInputView = Backbone.Marionette.ItemView.extend({ mixins: [pageflow.inputView], template: 'pageflow/ui/templates/inputs/check_box', className: 'check_box_input', events: { 'change': 'save' }, ui: { input: 'input', label: 'label' }, onRender: function() { this.ui.label.attr('for', this.cid); this.ui.input.attr('id', this.cid); this.load(); this.listenTo(this.model, 'change:' + this.options.propertyName, this.load); }, save: function() { if (!this.options.disabled) { this.model.set(this.options.propertyName, this.ui.input.is(':checked')); } }, load: function() { if (!this.isClosed) { this.ui.input.prop('checked', this.displayValue()); } }, displayValue: function() { if (this.options.disabled && this.options.displayUncheckedIfDisabled) { return false; } else { return this.model.get(this.options.propertyName); } } });
Version data entries
58 entries across 58 versions & 1 rubygems