I'm trying to get my head around structuring my client-side routes (in a 
reagent app) using secretary, and I'm struggling to work out the best way of 
dealing with the "redirect-after-post" scenario where I have a form that is 
submitted via AJAX, and once the AJAX request has successfully completed, I 
want to change to a different page to view the saved record.

The two ways I can think of to achieve this are:

1. Have the on-click event of the submit button make the ajax request, and have 
the success handler call secretary/dispatch! to the new page.

This has the disadvantage of not changing the url hash, so links back to the 
form don't work until you've changed pages again normally.

2. Replace the submit button with an anchor tag pointing at a different 
secretary route, something like /my-model/create, which makes the POST request 
and renders the new page. The problem with this approach is that you have to 
get the form data to the secretary route somehow, either by having it as params 
on the URL, which seems a bit pants, or by having it in a state atom that both 
the form and the secretary route knows about (which seems like data that 
shouldn't be shared).

How are other people doing this? Am I on completely the wrong track?

Thanks,

Russell

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to