Skip to content

Instantly share code, notes, and snippets.

@dennismonsewicz
Created February 11, 2014 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennismonsewicz/11c8bf6941a4515ae3d8 to your computer and use it in GitHub Desktop.
Save dennismonsewicz/11c8bf6941a4515ae3d8 to your computer and use it in GitHub Desktop.
CoffeeScript for dynamic form
ready = ->
if $('body').hasClass 'service_requests'
template = $('#blank_template').html()
$('.add_more').on 'click', (event)->
new_object_id = new Date().getTime()
html = template.replace /index_to_replace_with_js/g, new_object_id
$('#nested_items').append '<div class="new_item">' + html + '</div>'
$('.new_item select').selectpicker()
event.preventDefault()
$(document).ready(ready)
$(document).on('page:load', ready)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment