Topic: Unable to properly clone form with select
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 3 years 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
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 3.10.1
- Device: PC
- Browser: Edge
- OS: Windows
- Provided sample code: No
- Provided link: Yes