-
Aug 29th, 2014, 08:51 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] How to keep form submittal from navigating away from page
Noob alert!
I have a dojo dialog box that has a form on it. When I submit the values on the form to the server, the dialog dismisses like I want it to, but the whole page navigates away from where it is. I want to have the form on the dialog submit the info and dismiss, but leave the original page where it is.
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Aug 29th, 2014, 08:00 PM
#2
Re: How to keep form submittal from navigating away from page
What code are you using at the moment?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Aug 30th, 2014, 08:28 AM
#3
Thread Starter
Frenzied Member
Re: How to keep form submittal from navigating away from page
Right now I'm not using any code to post to the server - it's just a standard html form:
HTML Code:
<form action="~/FeatureDetails/EditFeature?MapFeatureID=@Model.TheFeature.Id&MapLayerId=@Model.TheLayer.LayerId" method="post" >
<!-- form elements -->
<p><input type="submit" value="OK" /></p>
</form>
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Aug 30th, 2014, 09:01 AM
#4
Thread Starter
Frenzied Member
Re: How to keep form submittal from navigating away from page
My apologies - I failed to indicate in the first post that this is an mvc app. Maybe that will help clear things up?
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Aug 31st, 2014, 06:57 PM
#5
Re: How to keep form submittal from navigating away from page
Having a "submit" button on your form will cause the form to post it's contents to the "action" url when the submit button is clicked. Sounds like you would want to change it to a regular button, either <input type="button" /> or <button type="button"></button> and then do an ajax post to the form's action url.
-
Sep 1st, 2014, 02:51 AM
#6
Re: How to keep form submittal from navigating away from page
I've moved the thread to the MVC section. You're likely to get better responses here.
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
-
Sep 1st, 2014, 05:20 AM
#7
Re: How to keep form submittal from navigating away from page
As it's an MVC app, you should be using Ajax.BeginForm to create your form element. If you didn't want an asynchronous post then you should be using Html.BeginForm.
-
Sep 1st, 2014, 06:46 AM
#8
Thread Starter
Frenzied Member
Re: How to keep form submittal from navigating away from page
I got snookered on Ajax.BeginForm since it's tied to the jQuery toolkit - I'm confined to using the dojo toolkit. I've found some example dojo code to perform the partial postback when the submit button is clicked, but it isn't working exactly right. Gonna have to do some more research.
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Sep 1st, 2014, 07:14 AM
#9
Re: How to keep form submittal from navigating away from page
Originally Posted by dolot
I got snookered on Ajax.BeginForm since it's tied to the jQuery toolkit
It's nothing to do with jQuery. It's part of the MVC Framework.
-
Sep 1st, 2014, 07:31 AM
#10
Thread Starter
Frenzied Member
Re: How to keep form submittal from navigating away from page
My understanding is that jQuery's unobtrusive-ajax script has to be loaded into the page for the code that's generated by the Ajax.BeginForm function to operate. Am I wrong on that?
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Sep 1st, 2014, 07:49 AM
#11
Re: How to keep form submittal from navigating away from page
Originally Posted by dolot
My understanding is that jQuery's unobtrusive-ajax script has to be loaded into the page for the code that's generated by the Ajax.BeginForm function to operate. Am I wrong on that?
Hmmm... I didn't think that that was the case but maybe I'm wrong.
-
Sep 1st, 2014, 02:39 PM
#12
Thread Starter
Frenzied Member
Re: How to keep form submittal from navigating away from page
Here's what I finally came up with. Fairly simple, and it works.
Code:
function SubmitFeatureData() {
require(["dojo/dom", "dojo/request", "dojo/dom-form"],
function (dom, request, domForm) {
var form = dom.byId('FeatureDetails');
// Post the data to the server
request.post("/FeatureDetails/EditFeature", {
// Send the username and password
data: domForm.toObject("FeatureDetails"),
// Wait 2 seconds for a response
timeout: 2000
}).then(function (response) {
// dom.byId('svrMessage').innerHTML = response;
});
}
);
}
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|