Sha256: c071cc4417e37d09a8e8022afb90644d0a56faff501fd1a64bea8488a2e0909e
Contents?: true
Size: 1.07 KB
Versions: 9
Compression:
Stored size: 1.07 KB
Contents
slices.ComposerItemView = Backbone.View.extend({ tagName: 'li', className: 'composer-item', template: Handlebars.compile( '<div class="item-fields"></div>' + '<span data-role="drag-handle"></span>' + '<span data-action="remove">Remove</span>' ), events: { 'change': 'update' }, initialize: function() { _.bindAll(this); this.$el.data('model', this.model); }, render: function() { $(this.el).html(this.template(this)); this.renderFields(); return this; }, renderFields: function() { if (!_.isFunction(this.options.fields)) return; this.$('.item-fields') .html(this.options.fields(this.model.attributes)) .applyDataValues() .initDataPlugins(); }, remove: function() { this.model.unbind('change', this.render); this.$el.remove(); }, update: function() { this.model.set(this.getValues()); }, getValues: function() { var result = {}; this.$('[name]').each(function() { var field = $(this); result[field.attr('name')] = field.val(); }); return result; } });
Version data entries
9 entries across 9 versions & 1 rubygems