Вопрос

I have several elements inside Ui form with default param (each):

'dependsOn' => 'assign_type'

and I want to get all that items inside the another js component of my form.

I try to use the uiRegistry (vendor/magento/module-ui/view/base/web/js/lib/registry/registry.js) like this:

uiRegistry.get('dependsOn = assign_type');

but in this case the registry ($p variable is uiRegistry object) returns only the first element:

element

elements index

This example from the documentation does not help:

* @example Requesting multiple elements.
*      registry.set('second', {index: 'test2'});
*      registry.get(['first', 'second'], function (first, second) {});

Result, got one item (first item) three times:

result of Requesting multiple elements example

Question is: How to receive several similar elements using the registry? Perhaps somebody knows other way?

Это было полезно?

Решение

Sorry, I found an answer. The filter method return all items by search criteria in the array:

    /**
     * Retrieves a collection of elements that match
     * provided search criteria.
     *
     * @param {(Object|String|Function)} query - Search query.
     *      See 'get' method for the syntax examples.
     * @returns {Array} Found elements.
     */
    filter: function (query) {
        return find(getItems(this), query, true);
    },

so, if I use $p.filter('dependsOn = assign_type') (where the $p is uiRegistry object) I receive all items:

result

Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top