cancel
Showing results for 
Search instead for 
Did you mean: 

Magento_Ui/templates/form/element/select.html how to add call custom dropdown

Magento_Ui/templates/form/element/select.html how to add call custom dropdown

Hi all,

I'm trying to call custom jQuery library for <select> element, particularly for this select

Magento_Ui/templates/form/element/select.html.

I have tried everything I found online but no luck. I tried to edit select.js by adding nothing

custom function and calling it on afterRender, I tried using x-magento-init, and so on. 

 

Can someone help me with concrete solution?

 

Thanks.

2 REPLIES 2

Re: Magento_Ui/templates/form/element/select.html how to add call custom dropdown

im not sure if u can use them on store front-end but i used form select element on admin page widget form like so:


            <parameter name="template" xsi:type="select" required="true" visible="true">
                <label translate="true">Template</label>
                <options>
                    <option name="default" value="Aedes_SlickProductsWidget::product/widget/content/grid.phtml" selected="true">
                        <label translate="true">Aedes Products Slider</label>
                    </option>
                    <option name="single-product" value="Aedes_SlickProductsWidget::product/widget/content/grid2.phtml" selected="false">
                        <label translate="true">Aedes Products Slider - single product</label>
                    </option>
                </options>
            </parameter>

also you can check form building example at vendor/magento/module-catalog-widget/etc/widget.xml

 

Re: Magento_Ui/templates/form/element/select.html how to add call custom dropdown

Sorry, but this wasn't what I asked. 

I need to have custom dropdown made from <select> element.

I have set this globally to all select elements by adding jQuery library and then calling it's 

function $('select').select2(); 

But it's not working for select elements that are being rendered with knockout, and that are rendered after initial page load.

For example cart-summary on cart page has shipping estimation form with <select> element that is rendered this way. So basically I would need to call library function after this element has been rendered but I can't find it's final init function.