1

I have a module which add layout to admin create order like this:

app/design/adminhtml/default/default/layout/mymodule.xml

<?xml version="1.0"?>
<layout>
    <adminhtml_sales_order_create_index>
        <reference name="before_body_end">
            <block type="mymodule/adminhtml_order" name="mymodule_admin_order_create" template="mymodule/admin_order_create.phtml"></block>
        </reference>
    </adminhtml_sales_order_create_index>
</layout>

I want to add my js file to the adminhtml_sales_order_create_index, but I don't know where to put the js file in my module directory and how to put it in the layout.

1
<?xml version="1.0"?>
<layout>
    <adminhtml_sales_order_create_index>
          <reference name="head">
            <action method="addJs">
             <script>my_extension/adminhack.js</script></action>                        
        </reference>
        <reference name="before_body_end">
            <block type="mymodule/adminhtml_order" name="mymodule_admin_order_create" template="mymodule/admin_order_create.phtml"></block>
        </reference>
    </adminhtml_sales_order_create_index>
</layout>

Please replace above code in your layout file and add JS file in js/my_extension/adminhack.js. Don't forget to clear cache.

4
  • i got console error saying js file not found – nortonuser Dec 14 '17 at 6:26
  • which URL you have added in layout file? – Nits Dec 14 '17 at 7:31
  • i've fixed it by moving to js folder – nortonuser Dec 14 '17 at 7:41
  • Okay Please correct/vote to my answer, if its helpful for you. – Nits Dec 14 '17 at 8:30
1
<?xml version="1.0"?>
<layout>
    <adminhtml_sales_order_create_index>
        <reference name="head">
            <action method="addJs"><script>path/file_name.js</script></action>
        </reference>
        <reference name="before_body_end">
            <block type="mymodule/adminhtml_order" name="mymodule_admin_order_create" template="mymodule/admin_order_create.phtml"></block>
        </reference>
    </adminhtml_sales_order_create_index>
</layout>
2
  • where to put the js file? – nortonuser Dec 14 '17 at 4:57
  • your mymodule.xml file – Ramesh S Dec 14 '17 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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