Topic: mdb-autocomplete clear button submits form

itay pro asked 5 years ago


How can I prevent mdb-autocomplete clear button to submit form ?

Here is my form element:


<form [formGroup]="form" (ngSubmit)="submit()">


Damian Gemza staff commented 5 years ago

Dear mdb2, Could you please provide me the full code in which you're getting the wrong behavior? It would help me to debug your problem. Also please describe your problem more broadly. PS: In the case of future reports, please try to provide the full code that causes the problems, and describe the situation in detail. This will greatly speed up the entire problem-solving process. Best Regards, Damian

itay pro commented 5 years ago

It is a part of a big program which obviously I don't want to share publicly here. If you want we can setup a screen share call and I can show you everything there Better send me an email as I don't get email notifications from this form

Arkadiusz Idzikowski staff commented 5 years ago

Dear mdb2, What we need the most is detailed information about the context in which our product is used in the user's application - code associated with our components and steps we should take to reproduce the problem. If you use ngSubmit and have multiple buttons in your form, then every button click will submit the form. This happens because in most browsers default type of button is "submit". To fix that you need to pass $event to function you call with button click and use event.preventDefault() method or add type="button" to those buttons that shouldn't submit the form. I hope this is what you tried to achieve. Best, Arek

itay pro answered 5 years ago


I associated the submit callback to the submit button and not to the form as you suggested and it is OK now Thanks

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: Yes
  • Provided link: No
Tags