Sha256: b9df0f3c04865f3b0524240e87c6c56b57518e232df7064e6f571dfe4ce82da2

Contents?: true

Size: 672 Bytes

Versions: 8

Compression:

Stored size: 672 Bytes

Contents

import Vue from 'vue';
import $ from 'jquery';

export default Vue.component('repeater-field', {

  props: {
    rowCount: {
      type: Number
    }
  },

  data: function() {
    return {
      rows: []
    }
  },

  created: function() {
    if (this.rowCount === 0) {
      this.addRow();
    }
  },

  methods: {
    addRow: function() {
      this.rows.push({ id: Math.uid() });
    },
    removeRow: function(row) {
      this.rows.$remove(row);
    }
  },

  directives: {
    removeRow: {
      bind: function() {
        $(this.el).on('click', function(e) {
          e.preventDefault();
          $(this).closest('tr').remove();
        })
      }
    }
  }

})

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
push_type_admin-0.12.1 app/webpack/javascripts/components/repeater-field.es6
push_type_admin-0.12.0 app/webpack/javascripts/components/repeater-field.es6
push_type_admin-0.12.0.beta.1 app/webpack/javascripts/components/repeater-field.es6
push_type_admin-0.11.2 app/webpack/javascripts/components/repeater-field.es6
push_type_admin-0.11.1 app/webpack/javascripts/components/repeater-field.es6
push_type_admin-0.11.0.beta.2 app/webpack/javascripts/components/repeater-field.es6
push_type_admin-0.11.0.beta.1 app/webpack/javascripts/components/repeater-field.es6
push_type_admin-0.10.4 app/webpack/javascripts/components/repeater-field.es6