Sha256: eabd410e243f5f1e95fe646548ed296666aed62a8120bec71efc7fa03baf6ce9
Contents?: true
Size: 1.68 KB
Versions: 46
Compression:
Stored size: 1.68 KB
Contents
/** * Text based input view that can display a placeholder. * * @param {string|function} [options.placeholder] * Display a placeholder string if the input is blank. Either a * string or a function taking the model as a first parameter and * returning a string. * * @param {string} [options.placeholderBinding] * Name of an attribute. Recompute the placeholder function whenever * this attribute changes. * * @param {boolean} [options.hidePlaceholderIfDisabled] * Do not display the placeholder if the input is disabled. * * @param {Backbone.Model} [options.placeholderModel] * Obtain placeholder by looking up the configured `propertyName` * inside a given model. * * @mixin * @memberof module:pageflow/ui */ pageflow.inputWithPlaceholderText = { onRender: function() { this.updatePlaceholder(); if (this.options.placeholderBinding) { this.listenTo(this.model, 'change:' + this.options.placeholderBinding, this.updatePlaceholder); } }, updatePlaceholder: function() { this.ui.input.attr('placeholder', this.placeholderText()); }, placeholderText: function() { if (!this.options.disabled || !this.options.hidePlaceholderIfDisabled) { if (this.options.placeholder) { if (typeof this.options.placeholder == 'function') { return this.options.placeholder(this.model); } else { return this.options.placeholder; } } else { return this.placeholderModelValue(); } } }, placeholderModelValue: function() { return this.options.placeholderModel && this.options.placeholderModel.get(this.options.propertyName); } };
Version data entries
46 entries across 46 versions & 1 rubygems