var form = $('form#create_topics');
form.on("submit",function(e) {
e.preventDefault();
if(condition matches){
form.submit();
}
});
Form submit prevent not working
문제
I got a meany on my hands. I often use regular buttons instead of submit type buttons to have a bit more control over my forms. In this case I am trying to submit a form that is not present on the initial load, but is rather imported if the user makes the choices that lead to that.
To keep things simple I have added the .on("submit") to the same scope as where I trigger the submit, just to prevent jquery from getting confused.
var form = $('form#create_topics');
form.submit();
form.submit(function(e) {
console.log("test");
e.preventDefault();
e.stopPropagation();
return false;
}
The submitting works, the preventing default processing does not. Not I have already tried .on("submit", function(e) and I have already tried form.submit(); after binding the .submit :)
I am guessing the reason its not working is due to my specific situation, any ideas?
해결책
제휴하지 않습니다 StackOverflow