Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JQuery ->
- $('a#add_image_form').click ->
- regex = /add_image_form_\d{1,3}/
- data = $(this).attr('data').toString()
- imgId = data.match(regex)[0].match /\d{1,3}/
- newId = parseInt(imgId) + 1
- newData = "add_image_form_".concat(newId)
- $(this).attr('data', newData)
- $(this).parent().before("
- <p>
- <label for='gallery_pictures_attributes_#{newId}_caption'>Caption</label>
- <input id='gallery_pictures_attributes_#{newId}_caption' name='gallery[pictures_attributes][#{newId}][caption]' size='30' type='text' />
- </p>
- <p>
- <input id='gallery_pictures_attributes_#{newId}_image' name='gallery[pictures_attributes][#{newId}][image]' type='file' />
- </p>
- ")
Add Comment
Please, Sign In to add comment