Question

I have created a Magento admin form with following fields.

    $skuField = $fieldset->addField(
        'sku',
        'text',
        [
            'name' => 'sku',
            'label' => __('SKU'),
            'title' => __('SKU'),
            'required' => true
        ]
    );
    $fieldset->addField(
        'product_name',
        'text',
        [
            'name' => 'product_name',
            'label' => __('Product Name'),
            'title' => __('Product Name'),
            'required' => false,
            'readonly' => true
        ]
    );
    $skuField->setAfterElementHtml("   
        <script type=\"text/javascript\">
            require([
                    'jquery',
                    'mage/template',
                    'jquery/ui',
                    'mage/translate'
                ],
                function($, mageTemplate) {
                    $('#edit_form').on('focusout', '#item_sku', function(event){
                        $('#item_product_name').val($('#item_sku').val);
                    })
                }
            );
        </script>"
    );

jQuery function works, if I use "change" event instead of "focusout". I searched web for solution and did not find. May I know the correct event name for focus out ?

Was it helpful?

Solution

blur worked. Also, changed

$('#item_product_name').val($('#item_sku').val);

to

$('#item_product_name').val($('#item_sku').val());
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top