Will
Will

Reputation: 1933

Knockoutjs click binding on parent prevents submit of child form

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!

Upvotes: 2

Views: 1562

Answers (1)

RP Niemeyer
RP Niemeyer

Reputation: 114802

If you return true from your doSomething method, then it will allow the default action to proceed.

Upvotes: 4

Related Questions