Newbie here, scratching my head on this one.
How do you normally save information specified in a popup dialog for use by other forms on your page?
Scenaro:
Click an options button, which pops up a dialog.
Set some checkboxes, radio buttons, etc...
Submit form (dialog seems to need it's own form)
Do you usually just save the inputs in a session, cookie, or do you have another way access your dialog controls from the main form?
Seems like I'm missing something basic, as it should be easy to set some options and use them on the rest of the page.
All advice appreciated!
If you are trying to pass data from one page/dialog to another see Passing parameters between pages
Related
I have a simple scaffold and I want the user to see (preview) the form data before he submits it. It looks to be fairly straight forward problem but surprisingly I am not able to figure out how to do it. I found this but it looks to be somewhat dated (2010 question)
Is there any gem or jquery plugin which can simplify this preview functionality ? any suggestions on how to do it in rails 3.2.x ?
Thanks
It really depends on what kind of "preview" you want to include - either "preview page" or "rendered fragment":
Preview page is what some services are showing: summary of all inputs shown in form of separate page with button "confirm". It doesn't require javascript or anything fancy - just click "next" on form page, see data typed just a second ago and click "confirm" or "back to edit". If this is what you require then you can do it simply by creating new controller action(preview?) which would initialize model with passed parameters(just like "create" action would, but without saving) and generate template with "preview" shown and hidden form that will be passed to "create" action after clicking "confirm". Alternatively you can simply modify "new" form so it would hide form depending on called action and show preview instead.
Second option is "render fragment" - it will live-update part of your current page via javascript. Depending on how complicated this view will be and what kind of operations you will need to do before showing template it might be good to use some javascript plugin or send request to server and obtain rendered partial. In former case you can select from very easy implementations(like this) up to complete solutions dedicated to it. On the other hand if you choose to render it on server then simple ajax request with all params of form should be enough to provide you with HTML output that can be put directly into DOM element.
I don't know about any gem which can do that.
I think showing a modal with jquery and getting data from data-elements is a simple way to go.
I want the html.checkbox() in ASP.NET MVC to be as a link that goes to an action controller (GET and not POST).
Question:
It is possible to make the html.checkbox() to act as a "actionlink" instead of going to the FormCollection without using Javascript and JQuery or any additional plugin?
This wouldn't be possible in any framework as checkboxes are just static input elements. They have no ability to trigger any sort of action on their own, hence where javascript and event handlers comes in.
You could try making a form who's method is GET, but it would still have to go somewhere.. I guess you could make an action that handles various states of a checkbox and then routes to the correct page, however you'd still need to submit this form by having the user click a submit (again because the only way to trigger an action from clicking a checkbox is by using javascript)
You could also fake a checkbox using css and checkbox-like images.
text goes here
If you need to show it as either checked or unchecked, you would use two classes with two different checkbox-like images.
I doubt this is possible without javascript.
Except for buttons and links, no controls actually do anything but change their own value in the DOM.
It would however be rather trivial to add an onclick to your checkbox that would do whatever (including a GET request).
I am using the method from this question to create a pop-up to show a form where the user must "sign" it and then click submit. I have the pop-up working and displaying data. Now I want to submit the form to a POST action and close the pop-up if the POST was successful.
I have been scouring the internet looking for something close to what I think I am looking for, but seeing anything. Can someone offer me some direction?
You can either do it manually via http://api.jquery.com/jQuery.post/ (it has on success callback) or use jQuery ajax form plugin http://jquery.malsup.com/form
I'm new to mvc so I don't know if there is a trick to this or not. When a user runs a search on a site I'm building and I take them to the results page, if I click the back button the search form is empty. Is there some way to keep the form fields populated as they were when going back (without resorting to session)? Thanks.
Strange.
Fields should be there by default. What browser are you using?
If you're using a regular browser, then maybe your doing something weird, like, resetting the fields via JavaScript or something. Perhaps elaborating more on your current implementation would help diagnosing your problem?
A last solution would be saving the fields as a cookie and loading them via JavaScript on the forms page inside onLoad.
I'm trying to use the jquery UI dialog component to display a form; which I successfully did.
However I'm at lost on how to retrieve data to this form inside the dialog window. Is it possible? The example shown on jquery website only shows static messages.
Maybe you can tell us more about the problem. What data do you want do display and in which format is this data (is it form data, javascript objects, dom objects, etc.?)
You talked about a form which is shown via a dialog. Where do you want to access this form data (when the dialog is closed, opened, when the form is submitted, ...)?