Anton Shestakov <av6@dwimlabs.net>, Sun, 05 Jul 2015 22:24:12 +0800
Added tag 0.3.1 for changeset e91afe175ca4
static/js/framework/views/inline.js
Permissions: -rw-r--r--
var InlineEditorView = Backbone.View.extend({ initialize: function(options) { renderInput: function(options) { this.$input = $('<input>').attr('type', 'text').addClass('input-xlarge').val(options.target.text()); this.$input.keyup(function(e) { view.$saveButton.click(); view.$cancelButton.click(); this.$el.append(this.$input, this.$saveButton, this.$cancelButton); options.target.after(this.$el); renderTextarea: function(options) { this.$input = $('<textarea>').addClass('input-xlarge').attr('rows', 3).text(options.target.text()); this.$input.keyup(function(e) { view.$saveButton.click(); view.$cancelButton.click(); this.$el.append(this.$input, this.$saveButton, this.$cancelButton); options.target.after(this.$el); render: function(options) { this.$saveButton = $('<button>').addClass('btn btn-small btn-success').html('<i class="icon-white icon-ok"></i>'); this.$cancelButton = $('<button>').addClass('btn btn-small').html('<i class="icon-remove"></i>'); this.$el = $('<div>').addClass('inline-editor input-append'); this.$cancelButton.click(function() { this.$saveButton.click(function() { view.trigger('save', view.$input.val()); return this.renderInput(options); return this.renderTextarea(options); var CollectionViewWithInlineEditor = CollectionView.extend({ bindInlineEditable: function(model, selector) { model.$item.delegate(selector, 'click', function(e) { var attribute = $this.attr('data-model-attribute'); var inlineEditor = new InlineEditorView({ type: $this.attr('data-input-type') || 'input' inlineEditor.on('save', function(value) { model.adhoc(data).then(function() {