In my web application I have a form that is accessible from multiple screens. I'd like the Cancel button in the form to lead back to the previous page. The link_to 'Cancel', :back solution doesn't work if form is submitted before the Cancel button is pressed. In such case it simple refreshes the page, which is an expected behavior.
What is a path-independent alternative that ensures that the Cancel button always leads to the screen that the form was opened from?
You can use request.referer as a 'Cancel' button. But I'm not sure how it will handle the submit.
Another solution would be to store the page where the user came from in a session, and then redirect them back there
I programmed a few reusable forms by splitting them into a partial and then passing the URLs to the partial. This way the html is fully reusable. Looks not as pretty but it's clear what it does
Related
I am new to ASP.Net MVC, and still trying to wrap my head around the controller and passing data to the view and back.
Here is my question. I have a model in my view with a property that is "isEnabled", which can be true or false.
I have an edit button, and an enable/disable button. Edit just takes me to a new view with a form.
I want the enable/disable button to change the property of the model to enabled or disabled.
Right now I have two separate buttons. When I click on them, it fires the appropriate action from the controller (EnableModel, DisableModel), and just reloads the current view.
How can I make it so, if the model is disabled the button shows and fires the enable action, and when it is enabled, the button shows and fires the disable action.
So here are the options I thought of.
1. Two buttons, I hide them as needed. I can use an if statement to check if the model is showing or not in razor.
2. Use javascript two to the above
3. Use javascript to physically change the button
What would be the best method?
Alright so looking back can't believe I ever even asked this haha.
I went the javascript route. I had a single button, and a simple onClick javascript class that would handle the toggling.
I`m using persistence API in form builder, but i can't redirecting orbeon form builder after pushing 'save' button. Anyone knows?
You probably want to look at the Buttons and Processes documentation. This allows you to create simple workflows when a button is pressed. So you could have a button which saves, then redirects to another page.
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?
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.
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.
As the title suggests, I am wondering how to create a checkbox on a view that will change what form is rendered without refreshing the page.
In my app/views/home/ folder I have _form_1.html.erb and _form_2.html.erb.
I want to default to <%= render 'form_1' %> when the box is not checked, and change to <%= render 'form_2' %> when the box is checked.
I've attempted to look up how to do this, but things like .is(":checked") and check_box_tag don't seem to be working for me, or I'm using them wrong.
Any help is appreciated!
EDIT: I am using Rails 3.2.12 and Ruby 1.9.3.
The way I'd do this is to render both the form partials from another view, and put each of them in a div. The default form div should be visible, and the optional form div should be hidden. Then you can toggle the display of the divs with a click action on the checkbox.
Depending on what's in the forms and how they interact with your controller, there's likely a lot of other work involved in processing, but in order to toggle the displayed forms, the method above is one option.
If you want to do this without a refresh you'll have to use javascript. What you'd do is render each form but as hidden. This next part is really easy with jquery. When a checkobox is selected you'd just do something like $('#form1').show(), and conversely $('#form2').hide()
I am developing a application in phonegap. In the app, there is a page which contains two textfields and a image. No submit button because I don't want to submit the form. the desired working is as follow..
the user taps the text fields, the keyboard appears.
clicking on the image below calls a javascript(jquery method-> $.post()) function which picks the data from the textfields and send it to server(json). that means I m not submitting the form.
and the go button on the virtual keyboard is supposed to submit the form. But in my case as I m not submitting the form so go button doesn't work and it doesn't look appropriate.
I want to get rid of the button..either it may dismiss the keyboard or call the jquery function which it is not supporting.
I searched a lot over the net. I came to know that if i remove the form tag the go button changes to return button which really worked then the return button again looks dumb.
So please help me to get rid of either of the button(preferably the return button).
I don't think you will be able to get rid off the button. What you could do instead, is to have the input field in form with and onsubmit event. This event should perform the jquery $.post method and return false to prevent standard form submission. This way your go button would actually work the way user expects and you don't have to disable it.