Module: ModalRails::Helper
- Defined in:
- lib/modal_rails/helper.rb
Instance Method Summary collapse
- #form_for_modal(record, options = {}, &block) ⇒ Object
- #link_to_modal(*args, &block) ⇒ Object
- #simple_form_for_modal(record, options = {}, &block) ⇒ Object
Instance Method Details
#form_for_modal(record, options = {}, &block) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/modal_rails/helper.rb', line 29 def form_for_modal(record, ={}, &block) [:format] = :modal [:remote] = true [:html] ||= {} [:html][:data] ||= {} [:html][:data][:action] = 'modal' form_for(record, , &block) end |
#link_to_modal(*args, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/modal_rails/helper.rb', line 3 def link_to_modal(*args, &block) if args[1].is_a? Hash or args[1].nil? url_index = 0 args_index = 1 else url_index = 1 args_index = 2 end args[args_index] ||= {} args[args_index][:remote] = true args[args_index][:data] ||= {} args[args_index][:data][:action] = 'modal' args[url_index].sub!(/([^\?]+)(\??.*)/, '\\1.modal\\2') unless args[args_index][:skip_force_format] link_to *args, &block end |
#simple_form_for_modal(record, options = {}, &block) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/modal_rails/helper.rb', line 20 def simple_form_for_modal(record, ={}, &block) [:format] = :modal [:remote] = true [:html] ||= {} [:html][:data] ||= {} [:html][:data][:action] = 'modal' simple_form_for(record, , &block) end |