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!