- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2018
04:18 PM
09-26-2018
04:18 PM
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.
Labels:
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2018
11:26 PM
09-26-2018
11:26 PM
Hello @tvgarden
Try this if helps you:
https://alanstorm.com/magento-2-ui-component-data-sources/
Manish Mittal
https://www.manishmittal.com/
https://www.manishmittal.com/
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2018
11:26 PM
09-26-2018
11:26 PM
Hello @tvgarden
Try this if helps you:
https://alanstorm.com/magento-2-ui-component-data-sources/
Manish Mittal
https://www.manishmittal.com/
https://www.manishmittal.com/
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2018
01:56 PM
09-27-2018
01:56 PM
Re: Ui Component - import array
@Manish Mittal Thank you for your reply.
I have read the page.
The problem was there was no 'Label' and 'Value' in the array.