6

i am using 1.8.2.jquery.min.js for slideshow in home page. i have an error in console like this

electronics.html (line 156) TypeError: element.attachEvent is not a function

element.attachEvent("on" + actualEventName, responder); prototype.js (line 5653)

TypeError: element.dispatchEvent is not a function

element.dispatchEvent(event); prototype.js (line 5734)

it makes menu drop-down in category page not working.

I have tried jquery noConflict(); in all the way in Magento but it does not clear above bug. Also, I have tried some more methods from google to clear but it does work properly. can anyone help me to clear this error?

closed as too broad by Marius, David Manners, mbalparda, Keyul Shah, Mufaddal Aug 7 '14 at 4:31

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • show your codes. Where did you include your jquery file. How are you trying to avoid jquery conflict. Be specific – Rajeev K Tomy Aug 6 '14 at 13:04
  • First Load your 1.8.2.jquery.min.js and then prototype.js – WisdmLabs Aug 6 '14 at 13:07
  • Check there may be more than one jquery files included.Remove all and replace by one. – saravanavelu Aug 6 '14 at 13:08
12

In your local.xml:

<reference name="head">
    <action method="addJs" name="jquery" as="jquery">
        <script>jquery-1.10.2.js</script>
    </action>
    <action method="addJs">
        <script>noconflict.js</script>
    </action>
</reference>

and noconflict.js would simply be

$j = jQuery.noConflict();

From there, anywhere you'd use $ for jQuery, you'd use $j instead.

Alternatively, if its just for a slideshow, and I assume you have something similar to

$(document).ready(function(){
    $('#target').slideshow();
})

you can do the following instead, and all the code within it would operate as normal:

jQuery(document).ready(function($){
     $('#target').slideshow();
});
  • 1
    I personally prefer using jQuery(...), you never know where your code will end up and it gets sloppy if some people use $j, while others use something different. – pspahn Aug 6 '14 at 20:26
  • 1
    @pspahn $j is the default in the new 1.9/1.14 rwd framework – philwinkle Aug 6 '14 at 20:30
  • thanks but its not working still i have same error. – Karthick Aug 8 '14 at 5:36
  • @Karthick what did you try? Do you still need help? – andyjv Oct 30 '14 at 15:12

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