Ngx-bootstrap: ngx- accordion - on group heading click form submits

Created on 16 Oct 2018  路  3Comments  路  Source: valor-software/ngx-bootstrap

I have used ngx-accordion  like
<form [formGroup]="Form" (ngSubmit)="Form()">
<input type="text" (ngModel)="fieldone" name="fieldone" />
<accordion>
<accordion-group heading="Heading">
<input type="text" (ngModel)="fieldtwo" name="fieldtwo" />
</accordion-group>
</accordion>
</form>

On browser view, when click on Heading form submit event fires because 
Heading render something like 
<button class="btn btn-link ng-star-inserted" ng-reflect-klass="btn btn-link" ng-reflect-ng-class="[object Object]">Heading </button>

how should i add type="button" in button tags

Most helpful comment

I'm affected by this issue as well. To clarify, Bootstrap do explicitly specify the type attribute for buttons (https://getbootstrap.com/docs/4.1/components/collapse/#accordion-example), as the default value is submit for a button (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type)

I've created a new bug as this one is closed. #5206 5206

All 3 comments

@Varun-Saini
We adhere to the behavior of the Bootstrap functionality.
Also, you shouldn't add type="button" into button tag.

I'm affected by this issue as well. To clarify, Bootstrap do explicitly specify the type attribute for buttons (https://getbootstrap.com/docs/4.1/components/collapse/#accordion-example), as the default value is submit for a button (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type)

I've created a new bug as this one is closed. #5206 5206

Workaround
enclose the <accordion> with a similarity div statement:

<div onclick="return false;">

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PascalHonegger picture PascalHonegger  路  3Comments

webdev48 picture webdev48  路  3Comments

MrBlaise picture MrBlaise  路  3Comments

ctrl-brk picture ctrl-brk  路  3Comments

MihaiHoriaPopescu picture MihaiHoriaPopescu  路  3Comments