Hi I would like to know how to import an array to a ui-select. With this code it does not display any options.
define([ 'jquery', 'underscore', 'uiRegistry', 'Magento_Ui/js/form/element/select', 'Magento_Ui/js/modal/modal', 'mage/url' ], function ($, _, uiRegistry, select, modal, url) { 'use strict'; return select.extend({ /** * On value change handler. * * @param {String} value */ onUpdate: function (value) { console.log('Selected Value: ' + value); // var field1 = uiRegistry.get('index = field1'); var field2 = uiRegistry.get('index = field2'); // // field2.hide(); // var field3Depend1 = uiRegistry.get('index = field3Depend1'); // console.log(require.toUrl('')); // console.log(field2.visibleValue); var linkUrl = url.build('customajax'); $.ajax({ url: '../../index/customajax', showLoader: true, data: {form_key: window.FORM_KEY, 'value':value}, type: "POST", dataType : 'json', success: function(data){ console.log(data.array); uiRegistry.get('index = attribute_item_value').options(data.array); } }); return this._super(); }, }); });
Solved! Go to Solution.
Hello @tvgarden
Try this if helps you:
https://alanstorm.com/magento-2-ui-component-data-sources/
Hello @tvgarden
Try this if helps you:
https://alanstorm.com/magento-2-ui-component-data-sources/
@Manish Mittal Thank you for your reply.
I have read the page.
The problem was there was no 'Label' and 'Value' in the array.