Sha256: 6f19d7618fac26bac49d7ba2d62f671f77cc19ae1414105565abfa17a21c5309

Contents?: true

Size: 529 Bytes

Versions: 3

Compression:

Stored size: 529 Bytes

Contents

$ ->
  $(document).off 'click', 'form .remove_fields'
  $(document).off 'click', 'form .add_fields'
  
  $(document).on 'click', 'form .remove_fields', (event) ->
    $(this).prev('input[type=hidden]').val('1')
    $(this).closest('.fields').hide()
    event.preventDefault()

  $(document).on 'click', 'form .add_fields', (event) ->
    console.log "test"
    time = new Date().getTime()
    regexp = new RegExp($(this).data('id'), 'g')
    $(this).before($(this).data('fields').replace(regexp, time))
    event.preventDefault()

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dynamic_fields_for_rails-0.2.0 app/assets/javascripts/dynamic_fields_for.coffee
dynamic_fields_for_rails-0.1.0 app/assets/javascripts/dynamic_fields_for.coffee
dynamic_fields_for_rails-0.0.1 app/assets/javascripts/dynamic_form_for.coffee