cancel
Showing results for 
Search instead for 
Did you mean: 

UI component select box on change event call ajax

Highlighted

UI component select box on change event call ajax

How can I add an event when changes select box dropdown value and I will trigger Ajax when change value in the dropdown,
Below is my code.

<fieldset name="sample_fieldset">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="label" xsi:type="string" translate="true">Attribute Information</item>
            </item>
        </argument>
        <field name="attr">
            <argument name="data" xsi:type="array">
                <item name="options" xsi:type="object">vendor\module\Model\Source\option</item>
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="label" xsi:type="string" translate="true">Select Attribute</item>
                    <item name="formElement" xsi:type="string">select</item>
                    <item name="source" xsi:type="string">splitattr</item>
                    <item name="dataScope" xsi:type="string">attr</item>
                    <item name="default" xsi:type="string">0</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>
                    </item>
                </item>
            </argument>
        </field>

Below is the output which created image (1).png

How can I get selected value in jquery

1 REPLY 1
Highlighted

Re: UI component select box on change event call ajax

Hi @Pushpendra7 ,

 

Please check below url for adding ui component custom js and you can get the selected value and call ajax.

https://magento.stackexchange.com/questions/153740/magento-2-field-dependency-in-ui-form

https://stackoverflow.com/questions/57189359/magento-2-how-to-add-dynamic-url-for-ajax-call-from-uic...

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!