Created
October 21, 2021 09:34
-
-
Save jlnarvaez/44951dc46952599d25de514e02839466 to your computer and use it in GitHub Desktop.
[Magento 2] UI Components - uiRegistry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Initialice uiRegistry (for Chrome debug) | |
var uiRegistry = require('uiRegistry'); | |
// Get all UI Components names registered on the page | |
uiRegistry.get(uiItem => console.log(uiItem.name)); | |
// Get all UI Components index registered on the page | |
uiRegistry.get(uiItem => console.log(uiItem.index)); | |
// Get a specific UI Component by name | |
uiRegistry.get('custom_field'); | |
// Get a specific UI Component by index (id) | |
uiRegistry.get('index = plan_id'); | |
// Get a specific UI Component value by index (id) | |
uiRegistry.get('index = plan_id').value(); | |
// Set value to a "select" UI Component by index (id) | |
uiRegistry.get('index = plan_id').setOptions([{label: 'Item 1', value: 1}, {label: 'Item 2', value: 2}]); | |
// Create a new property on a UI Component | |
uiRegistry.get('index = plan_id').set('test', 'value'); | |
// Remove a property of a UI Component | |
uiRegistry.get('index = plan_id').remove('test'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment