Skip to content

Instantly share code, notes, and snippets.

@jtadeulopes
Created June 21, 2009 00:59
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 jtadeulopes/133346 to your computer and use it in GitHub Desktop.
Save jtadeulopes/133346 to your computer and use it in GitHub Desktop.
module Web::AdsHelper
def add_picture(form)
link_to_function 'Adicionar outra imagem' do |page|
form.fields_for :pictures, Picture.new, :child_index => 'NEW_RECORD' do |f|
html = render(:partial => 'fields_pictures', :locals => {:f => f})
# caso use prototype, inserir a linha abaixo
# $('pictures').insert({ bottom: "#{ escape_javascript html }".replace(/NEW_RECORD/g, new_picture_id) });
page << %{
var new_picture_id = new Date().getTime()
$('#pictures').after("#{escape_javascript html}".replace(/NEW_RECORD/g, new_picture_id));
}
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment