jamesfzhang
jamesfzhang

Reputation: 4483

Show different partial in Controller#show

I have 3 different partials, each representing a different step of this process: "_overview.slim", "_setup.slim", and "_submit.slim". I want to show these 3 different partials all in "show.slim" only one at a time, and one after another as the user clicks on "Go to next step". How can I accomplish this in the show action of my controller?

Upvotes: 0

Views: 61

Answers (2)

Nich
Nich

Reputation: 1102

Let say in your show,have a 'Next' button to trigger the next partial.

In the 'Next' button, I can pass a param[:page1] and all the necessary param when click. In the 'Show', if there is param[:page1] ,then display _partial1.html.erb

its goes all the same.

Upvotes: 2

Mgrandjean
Mgrandjean

Reputation: 317

So if I were you, I would put render all three partials in your show view, and use Javascript, and CSS to manage when each one was shown. If you drop each of those partials in a div, its easy to use JQuery's hide and show methods, linked to the click event of the "Go To Next Step" button. To do it this way you wouldn't have to touch your Controller at all.

Upvotes: 1

Related Questions