Ajax server side concerns and folder structure
jnicho02 opened this issue · comments
I really like this gem. However, i'm starting to use rails_ujs and have a problem...
Updating from a form_with via an Ajax data remote autotriggers a call to update.js.erb.
As the step views are in a single folder I cannot see how to have different update.js.erbs for each step. (see https://guides.rubyonrails.org/working_with_javascript_in_rails.html#server-side-concerns)
Perhaps there a quick way to change from having 'step_one.html.erb', 'step_two.html.erb', etc. to 'step_one/show.html.erb', 'step_two/show.html.erb'? or maybe something else?
with careful naming of element ids so that they don't clash I can probably use the same update.js.erb for every page in the wizard. Not ideal, but works for now.
Perhaps there a quick way to change from having 'step_one.html.erb', 'step_two.html.erb', etc. to 'step_one/show.html.erb', 'step_two/show.html.erb'? or maybe something else?
There's probably a method you could monkey patch to accomplish that.
just solved it.... 'update.js.erb' is a the default render for format.js, but you can of course specify whatever you like.
def update
.....
respond_to do |format|
format.html { render_wizard @project }
format.js { render "#{step}"}
end
will autorun "/[wizard name]/[step name].js.erb