Knockoutjs click binding on parent prevents submit of child form
-
27-10-2019 - |
Question
Check out this jsfiddle. There is a <div>
with a click binding. This div has a child form. Clicking the submit button on the child form fires the parent click event, and does not submit the form.
How can I restore the ability to submit this form? In my real-life application, I also have a file field in the form, which does nothing when it is clicked. I mention that just to avoid any answers like:
$('#myForm input[type=submit]').click(function(){
$('#myForm').submit();
});
Thanks!
Solution
If you return true
from your doSomething
method, then it will allow the default action to proceed.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow