Sha256: b16eea28494af65be80b3b9c69e6022fc9e5e884ae20a73d0aefd6bd7bafc370

Contents?: true

Size: 747 Bytes

Versions: 6

Compression:

Stored size: 747 Bytes

Contents

@app.directive 'repeaterField', ['$compile', '$timeout', ($compile, $timeout) ->
  {
    restrict: 'A'
    scope: true
    link: ($scope, $el, $attrs) ->
      $rows     = $('.rows', $el)
      template  = $('.template', $el).text()

      $scope.addRow = ->
        uid   = Math.uid()
        $row  = $(template)
        $row.attr 'data-uid', uid
        $rows.append $row
        $dom = $("[data-uid='#{ uid }']", $rows)
        $compile($dom)($scope)
        $timeout -> $dom.trigger('init.fndtn')
        true

      $scope.addRow() unless $rows.children().length
  }
]

@app.directive 'repeaterRow', ->
  {
    restrict: 'A'
    scope: true
    link: ($scope, $el, $attrs) ->
      $scope.removeRow = ->
        $el.remove()
        true
  }

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
push_type_admin-0.7.0 app/assets/javascripts/push_type/fields/repeater_field.js.coffee
push_type_admin-0.7.0.beta.1 app/assets/javascripts/push_type/fields/repeater_field.js.coffee
push_type_admin-0.6.0 app/assets/javascripts/push_type/fields/repeater_field.js.coffee
push_type_admin-0.6.0.beta.4 app/assets/javascripts/push_type/fields/repeater_field.js.coffee
push_type_admin-0.6.0.beta.3 app/assets/javascripts/push_type/fields/repeater_field.js.coffee
push_type_admin-0.6.0.beta.2 app/assets/javascripts/push_type/fields/repeater_field.js.coffee