Sha256: ed7789a3f5e0d5d4394c3fb886ba59e553d9f61739cfc9bb6cad2ed0bb6830cb
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
module AnafHabtm module ApplicationHelperMethods def remove_child_link(name, form_builder) value = form_builder.object.new_record? ? "1" : "false" klass = form_builder.object.class.name.underscore form_builder.hidden_field(:_destroy, {:value=>value, "data-remove"=>klass}) + link_to(name, options={}, html_options={"href"=>"#", "class"=>"remove-child-link", :tabindex=> "0"}) end def add_child_link(name, child, form_builder) # puts "||#{form_builder}||" new_form = new_child_fields(child, form_builder) raw(content_tag(:div, new_form, {:id=>"#{child}_template", :class=>"form-template"}, escape=false))+ link_to(name, options={}, html_options={"href"=>"#", "class"=>"add-child-link", "data-class-name"=>child}) end def new_child_fields(child, form_builder) output = "" form_builder.fields_for(child.pluralize.to_sym, child.camelize.constantize.new, :child_index => "__#{child}_id__") do |f| output += render(:partial => child.underscore, :locals => { :f => f }) end output end def tfwac(f, field, controller, opts={}) opts["data-auto-complete"]=true opts["data-auto-complete-url"]=eval("#{controller.to_s.underscore.tableize}_path(:format=>:json)") f.text_field field, opts end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
anaf_habtm-0.0.85 | lib/anaf_habtm/application_helper_methods.rb |