How to close show view after clicking link

14 views
Skip to first unread message

Jim

unread,
Nov 27, 2018, 10:38:38 PM11/27/18
to ActiveScaffold : Ruby on Rails Gem
I added a link to a show action view to mark an item as processed. Using process_action_link_action in the action, the row is updated, but the show view is not updated and is still showing. Is there an easy way to close the show view as if the cancel link was also clicked? Alternatively, if the show view could be updated that would be ok as well.

Sergio Cambra

unread,
Nov 28, 2018, 3:34:45 AM11/28/18
to actives...@googlegroups.com, Jim

Hi

 

There is no way inside ActiveScaffold to update show view, if you want to update row and show view you have to write your own view. There is 2 ways:

 

Create app/views/controller/on_action_update.js.erb, call render :super and add code to update show view:

 

<%= render :super %>

<% if action_name == 'your custom action' %>

$('#<%= element_row_id action: :nested %> .show-view dl').replace('<%= j render('show_columns', columns: active_scaffold_config.show.columns, record: @record) %>');

<% end %>

 

Or you can write your own view, and change your controller to:

 

process_action_link_action(:your_action_name) do |record|

...

end

 

# your_action_name.js.erb

<%= render :partial => 'update_messages' %>

ActiveScaffold.update_row('<%= element_row_id(action: :list, id: @record.id) %>', '<%= j render('list_record', record: @record) %>');

ActiveScaffold.scroll_to('<%= element_row_id(action: :list, id: @record.id) %>', true);

<%= render :partial => 'update_calculations', :formats => [:js] %>

$('#<%= element_row_id action: :nested %> .show-view dl').replace('<%= j render('show_columns', columns: active_scaffold_config.show.columns, record: @record) %>');

 

El miércoles, 28 de noviembre de 2018 4:38:38 (CET) Jim escribió:

I added a link to a show action view to mark an item as processed. Using process_action_link_action in the action, the row is updated, but the show view is not updated and is still showing. Is there an easy way to close the show view as if the cancel link was also clicked? Alternatively, if the show view could be updated that would be ok as well.


--
You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to activescaffol...@googlegroups.com.
To post to this group, send email to actives...@googlegroups.com.
Visit this group at https://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.



Jim Crate

unread,
Nov 28, 2018, 5:23:33 PM11/28/18
to actives...@googlegroups.com, Sergio Cambra
Thank you so much for the help, it set me on the right track. My primary goal was to hide the show view after the user clicked the link, turned out to be easy. I overrode on_action_update.js.erb like this:

<%= render :super %>
<% if action_name == 'process_note' %>
ActiveScaffold.remove('<%= element_row_id action: :nested %>');
<% end %>

and it works perfectly.

Jim Crate
Reply all
Reply to author
Forward
0 new messages