0

I'm trying to create a custom text-area in admin panel and I need to attach the afterRender event to it.

Config XML:

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="behavior">
        <field name="behavior_field_feed_template">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">Feed Template</item>
                    <item name="visible" xsi:type="boolean">true</item>
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="formElement" xsi:type="string">textarea</item>
                    <item name="component" xsi:type="string">Feeds/js/form/export-feed-template</item>
                    <item name="source" xsi:type="string">export</item>
                    <item name="sortOrder" xsi:type="number">20</item>
                    <item name="dataScope" xsi:type="string">behavior_field_feed_template</item>
                    <item name="imports" xsi:type="array">
                        <item name="toggleVisibility" xsi:type="string">${$.parentName}.behavior_field_file_format:value</item>
                    </item>
                    <item name="valuesForOptions" xsi:type="array">
                        <item name="feeds_product" xsi:type="string">feeds_product</item>
                    </item>
                    <item name="notice" xsi:type="string">
                        To generate Feed you need to prepare template.
                        You can do this with existing templates which we've prepared for you or can create your own.
                    </item>
                </item>
            </argument>
        </field>
    </fieldset>
</form>

JS:

define(
    [
        'Magento_Ui/js/form/element/textarea',
        'Feed/js/lib/codemirror'
    ],
    function (Element, CodeMirror) {
        'use strict';

        return Element.extend(
            {
                defaults: {
                    valuesForOptions: [],
                    isShown: false,
                    inverseVisibility: false,
                    visible: false
                },

                afterRender: function() {
                    // Do something here!!!
                }
            }
        );
    }
);

What setting I'm I missing to achieve this? Thanks

0

So. All I had to do is to add 1 line into config: Feeds/form/template Then add this template into dir and add the "afterRender: afterRender" config into data-bind.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.