Sha256: ef991d9e0647bd9edf82bfdcb4f5db834d9a37ef163816cd4d3722f5229b5a8d
Contents?: true
Size: 1003 Bytes
Versions: 8
Compression:
Stored size: 1003 Bytes
Contents
pageflow.TextInputView = Backbone.Marionette.ItemView.extend({ mixins: [pageflow.inputView], template: 'templates/inputs/text_input', ui: { input: 'input' }, events: { 'change': 'onChange' }, onRender: function() { this.load(); this.validate(); }, onChange: function() { this.validate(); this.save(); }, save: function() { this.model.set(this.options.propertyName, this.ui.input.val()); }, load: function() { this.ui.input.val(this.model.get(this.options.propertyName)); }, validate: function() { if (this.options.required && !this.ui.input.val()) { this.displayValidationError('Muss ausgefüllt werden'); } else { this.resetValidationError(); } }, displayValidationError: function(message) { this.$el.addClass('invalid'); this.ui.input.attr('title', message); }, resetValidationError: function(message) { this.$el.removeClass('invalid'); this.ui.input.attr('title', ''); } });
Version data entries
8 entries across 8 versions & 1 rubygems