MarcRohrer free asked 2 years ago


what is the correct way to reset a whole form to its defaults?


robbyirish free commented 2 years ago

with jQuery I use $('#formID').trigger("reset");


MarcRohrer free answered 2 years ago


Hi,

Works, thank you!

Marc


MarcRohrer free answered 2 years ago


Hi,

I have a working version, thank you. Now I am working on loading data into the form, got from server via fetch. Works fine, but in the end the labels stay inside the edit elements. What function do I use to update that?

regards

Marc


Dawid Wajszczuk staff commented 2 years ago

Hi. Try this code and let me know if this works. https://mdbootstrap.com/docs/standard/forms/input-fields/#section-update

document.querySelectorAll('.form-outline').forEach((formOutline) => {
      new mdb.Input(formOutline).update();
});

Dawid Wajszczuk staff answered 2 years ago


Hi,

The best way would be to write the whole logic for this in JS. Second option, dispose all pieces of this form and reinitialize them. And the last solution that comes to my mind (and the simplest) would be to try using this https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset (I'm not fully aware how well it works with our kit but you can give it a try).

Keep coding,
Dawid



Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 3.9.0
  • Device: PC
  • Browser: Browser
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No