here I want to create a modal pop up when the button was a click, by using block file how can I pass the modal link through this below code…
public function getMainButtonsHtml()
{
$html = parent::getMainButtonsHtml();//get the parent class buttons
$addButton = $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Button')
->setData(array(
'label' => 'Add Amount',
'onclick' => "setLocation('redirect-url')",
'class' => 'amount'
))->toHtml();
return $addButton.$html;
}
Note: 'onclick' => "setLocation('redirect-url')"
, —-> here i want to pass the link ,Wheather it is possible???If yes please help.
Best Answer
You should create a module first, then after create a
requirejs-config.js
file atapp/code/Vendor/YourModule/view/frontend/requirejs-config.js
You need to create
myfile.js
inapp/code/Vendor/YourModule/view/frontend/web/js/myfile.js
Then your phtml file should look like:
Also you can refer to this link for more help:
Modal widget