Reputation: 43
Just a general question regarding submitting forms within a modal and the associated Action.
I have an existing standard form that scaffolding creates for you which uses the "Cases/CreateCase" action. This action would save the form and has a standard Redirect To Action to return Index.cshtml
I want to allow the user to do a shortened "Quick Case" version of this case form from the home page.
I have updated the Home/Index.cshtml to include a button which will open a modal (modal id = "createCaseModalForm") which contains a form for "Cases/CreateQuickCase" action. This is currently an ActionResult.
This uses similar logic to the previous "Cases/CreateCase" action, but this time rather than have a re-direct action for submission I simply want for the data to be saved and the modal to close. ID of the form is "#createQuickCaseForm"
Do I need ajax for this modal submission?
What should the Controller action return, since it has to return something. And should it be a different action type other than an "Action Result"??
Thanks
Upvotes: 1
Views: 537
Reputation: 36
If I got your question correctly then you want to achieve two goals.
To achieve this you can call the normal controller action and also write a jquery which will help you to close modal when submit button clicked.
JQuery code can be like: $('#YourSubmitButtonID').click(CLOSEMODAL)
Upvotes: 1