Reputation: 8742
I have a pipeline which I would like to work like this
Section A
Section B
I have section A implemented. The paths to the images are stored in form A's model. In summary A, when the user checks a photo, a javascript array variable is updated with the selected images' paths What I am having trouble with passing this javascript variable to form B
Is this possible? is there an alternative? Please let me know if I haven't explained my self well
Thanks
Upvotes: 1
Views: 350
Reputation: 1905
Supplying the javascript variable to Form B is straightforward -- you just add it as a global Javascript variable in the generated page. So your template would have:
<script type="text/javascript">
var theArrayData = @Html(theJavaScriptVariable.toString)
</script>
You could either recompute theJavaScriptVariable
in your controller before passing it to the template, or you may be able to submit it along with the rest of Form A as a hidden field, and cache it with the user's session. You would need to serialise it (e.g. with the jquery JSON library), and probably deal with escaping.
Upvotes: 2