Topic: Unable to properly clone form with select

mmmarkk01 priority asked 10 months ago


Expected behavior:

When using cloneNode() to duplicate a form I would expect the <select> to keep its options.

Actual behavior:

The <select> functionality breaks and no options can be selected.

Resources:

Press the 'Add formset' button in the snippet to see the bug:

https://mdbootstrap.com/snippets/standard/mmmarkk01/3646173#js-tab-view


Dawid Wajszczuk staff answered 10 months ago


Hi,

It won't work because you are copying Select elements which where generated via our script. They will still have the same ids. And you will not get options wrapper which is being render outside your form. Which is why you don't have options to choose from. You did not copy this part, which again will have the same ids.

You need to make new select for each form. If you want the same options, just create options object and pass it to these selects via JS.

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

  • User: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.10.1
  • Device: PC
  • Browser: Edge
  • OS: Windows
  • Provided sample code: Yes
  • Provided link: Yes