CreativeIT / getmdl-select

Select for material-design-lite
http://creativeit.github.io/getmdl-select/
MIT License
301 stars 87 forks source link

Dynamically add select #80

Closed OhhConti closed 6 years ago

OhhConti commented 6 years ago

I'm trying to use your select component, but I'm not able to add it dynamically, here is the code dyanmicallyselect.txt

femarschall commented 6 years ago

Your aproach is a bit messy and I don't know why the last node "Slider" is inside an "AP" element and not inside a "li" element as the previous others..

And you are not using the init function as stated in the instructions:

Dynamically usage For dynamically usage, you must add getmdlSelect.init(cssSelector)

femarschall commented 6 years ago

I made it work adding the following line after "componentHandler.upgradeDom();" :

getmdlSelect.init('#contenitore .getmdl-select:last-child');

alexbananabob commented 6 years ago

@femarschall, many thanks for your answer. It is right. @OhhConti, Hope @femarschall's answer helped you.