Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
Uncaught ReferenceError: addAdresar is not defined at HTMLInputElement.onclick

I created a modal popup with grid columns. This works well, my data is loaded into the grid. In the action column, I added a button that calls the function. But an error is always displayed. Apparently my js code is misspelled. Can someone please explain to me how to call a function?

This is my action column, which I need call my custom function: Vendor/Module/Ui/Component/Listing/Column/Action.php

public function prepareDataSource(array $dataSource)
    {
    if (isset($dataSource['data']['items'])) 
        {
        $fieldName = $this->getData('name');
        foreach ($dataSource['data']['items'] as & $item) 
            {
            if (isset($item['id'])) 
                {                   
                $html = '<input type="button" id="adresar" value="Přidat" onclick="addAdresar();">';
                $item[$fieldName] = $html;
                }
            }
        }
    return $dataSource;
    }

My JS map Vendor/Module/view/adminhtml/web/requirejs-config.js

    var config = {
map: {
    '*': {
        adresar: 'Vendor_Module/js/adresar',
    }
}
};

Now I need call my custom js function in this: Vendor/Module/view/adminhtml/web/js/adresar.js

require(
    [
        'jquery',
        'jquery/ui',
        'Magento_Ui/js/modal/modal'
    ],
    function($) {
        "use strict";
        return function addAdresar() {
            alert('Hello!');
            }          
    }
);

Thanks for any ideas!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!