form_selector = "#{element_form_id(:action => :create)}" insert_at ||= :top page << "var action_link = ActiveScaffold.find_action_link('#{form_selector}');" page << "action_link.update_flash_messages('#{escape_javascript(render(:partial => 'messages').strip)}');" if controller.send :successful? if render_parent? && controller.respond_to?(:render_component_into_view) parent_rendered = controller.send(:render_component_into_view, render_parent_options) if nested_singular_association? page << "action_link.close('#{escape_javascript(parent_rendered)}');" else if render_parent_action == :row page << "ActiveScaffold.create_record_row(action_link.scaffold(),'#{escape_javascript(parent_rendered)}', #{{:insert_at => insert_at}.to_json});" elsif render_parent_action == :index page << parent_rendered end page << "action_link.close();" end #page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?} elsif (active_scaffold_config.create.refresh_list) page.call 'ActiveScaffold.replace_html', active_scaffold_content_id, render(:partial => 'list', :layout => false) elsif params[:parent_controller].nil? new_row = render :partial => 'list_record', :locals => {:record => @record} page << "ActiveScaffold.create_record_row(action_link.scaffold(),'#{escape_javascript(new_row)}', #{{:insert_at => insert_at}.to_json});" page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?} end unless render_parent? if (active_scaffold_config.create.persistent) page << "action_link.reload();" else page << "action_link.close();" end if (active_scaffold_config.create.action_after_create) page << "var link = $('#{action_link_id active_scaffold_config.create.action_after_create, @record.id}');" page << "if (link) (function() { link.action_link.open() }).defer();" end end else page.call 'ActiveScaffold.replace', form_selector, render(:partial => 'create_form', :locals => {:xhr => true}) page.call 'ActiveScaffold.scroll_to', form_selector end