1

The RWD theme has several JQuery files such as rwd/default/js/app.js

I need to extends some of the functionality in this file, but it's not possible to do this in the traditional way that prototype does (Object.extend etc). Is it just a case of copying the file into my theme and doing as I please? Is this the accepted way of doing this type of work?

0

I guess at least there are two options for your case.

  1. If you want to rewrite it, you should make a copy of this file to you custom theme to avoid directly editing core file. It should be under js folder like that: your_thems/js/app.js then you can edit that one.

  2. Create your custom extension file, you can put it in skin folder or js folder depended on you flavour. Then inserting this file through local.xml. Finally, you can do your magic here.

an example: check here. That's the way to add a custom extension js in local.xml file. Hope it help you somehow.

<reference name="head">
    <action method="addJs"><script>js/my_app.js</script></action>
</reference>
  • That makes sense - I'm just disappointed that there's no way of extending Magento's JQuery in the same way you can with Prototype. – Adam Moss Mar 30 '16 at 8:31
  • In my opinion, it can be extendable, but ofcause you are write the syntax will different. I have some pains when I try to use both in the same place (the reason is I don't have any experience with Prototype.js so I try to use jQuery as much as I can).You may try to rewrite jQuery as a widget then you can extend it easily.At least, I have tried to write a widget to do float menu in this way.Maybe take a look about that one in the begining: learn.jquery.com/jquery-ui/widget-factory And as far as I know, Magento 2 will replace prototype.js completly by jQuery. :) so prepare for that. – Tiikeri Mar 30 '16 at 12:30

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.