vhochstein / active_scaffold

Rails 4 Version of activescaffold supporting jquery
MIT License
156 stars 34 forks source link

Feature request: "Save and continue editing" #66

Closed victor-ono closed 13 years ago

victor-ono commented 13 years ago

Is it possible to add a "Save and continue editing" button which would dynamically save the edits and refresh the form?

vhochstein commented 13 years ago

That s possible yes.

Copy on_update.js.rjs to you controller view directory and change it as follows: form_selector = "#{element_form_id(:action => :update)}"

page << "ActiveScaffold.find_action_link('#{form_selector}').update_flash_messages('#{escape_javascript(render(:partial => 'messages').strip)}');" if controller.send :successful? page.call 'ActiveScaffold.replace', form_selector, render(:partial => 'update_form', :locals => {:xhr => true}) page.call 'ActiveScaffold.scroll_to', form_selector page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?} else page.call 'ActiveScaffold.replace', form_selector, render(:partial => 'update_form', :locals => {:xhr => true}) page.call 'ActiveScaffold.scroll_to', form_selector end