views:

102

answers:

2

Hi all,

I'm interested in getting preview functionality working similar to how the 37signals job site does: http://jobs.37signals.com. Below are some screen shots of how it works.

So assuming you have Post model where Step 1 usually takes place in the new/create view/actions, how should one continue to Step 2 Preview and then after previewing, proceeding to the Step 3 publishing the post/ad?

Do they actually save the ad/post in the database before continuing to Step 2 (Preview) but set a flag (like a boolean field called preview set to true)? It looks like they set a token paramater but I'm not sure what it's used for)

I'm interested in this because it seems to go against the CRUD/REST and I thought it would be good to know how it worked.

Thanks!

A: 

You could easily use some jQuery to write the output of the form to a div for display before actually submitting the form to the server for saving/publishing

Jimmy
Hi Jimmy. Thanks for the answer although I don't think they did it via jQuery. Would be interesting if they did though. I think state_machine is probably the way they went about it.
slythic
It sounds like a solid approach, also I wasn't giving you an answer to how they did it just a simple solution to implement it yourself.
Jimmy
Got it! I've always avoided working with JS directly - not exactly sure why. JS would be ideal in theory as it doesn't have to access the db. *note to self - look into JS/jQuery* :-)
slythic
+1  A: 

They might be using a state_machine so when it is created it needs to be confirmed then when it is confirmed it needs to be paid. then they just hold the state in the db with the record

http://github.com/pluginaweek/state_machine

ErsatzRyan
State Machine looks like it could be the way to get this functionality working. Thanks!
slythic