I've successfully added a new button on a form container (near New, Save, Save and Continue) in backend. I tried to use ajax... first adding JS code in adminhtml/layout/default. But the js code I write does not recognize require or define statements, so I don't have access to requirejs/jquery. How can I properly include javascript in admin or how can I map a controller action to my custom button?

Any ideas?

1 Answer 1


please try:

Add javascript to content:

<referenceContainer name="content">
        <block class="Magento\Framework\View\Element\Template" name="protabs.script" template="Vendor_Module::script.phtml"/>

You can change Magento\Framework\View\Element\Template to your block

script.phtml (templates/script.phtml):

<script type="text/javascript">
], function(jQuery){
    (function($) {
        your script here...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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