Material: md-button always fires form's submit

Created on 20 Nov 2014  路  6Comments  路  Source: angular/material

Hi,

md-button always fires form ng-submit event even when type is not set to submit.

It also happens using

bug

Most helpful comment

Obviously it happens because "submit" is the default type of a <button> tag.
https://developer.mozilla.org/ru/docs/Web/HTML/Element/button

All 6 comments

Maybe it's related to https://docs.angularjs.org/api/ng/directive/form#submitting-a-form-and-preventing-the-default-action

@ajberasategui - useful link for everyone.

Please note that my Plunker was coded specifically for ARIA testing鈥搃t does not use the official recommended markup. I have updated it with a code comment reflecting such. http://plnkr.co/edit/np1n4JicBQEc2EuAgDQj?p=preview

Obviously it happens because "submit" is the default type of a <button> tag.
https://developer.mozilla.org/ru/docs/Web/HTML/Element/button

@WebTechnolog is right. (The link posted by @ajberasategui is useful indeed, but not related to this issue.)

@marcysutton: In your last plunkr, I think the problem is with the buttons above your comment (not below). The fix should be easy though: Just add type="button" to the "non-submit" button.

Indeed, this isn't an issue.

Was this page helpful?
0 / 5 - 0 ratings