Jump to content

Javascript in tpl files problem


Recommended Posts

Hi. I just started to play with prestashop so I have a question to ask. I'm trying to integrate a javascript in the tpl file. First I figured out that I have to put {literal} tags. After that prestashop won't crash, but the FireBug shows me the error " $("sublinks").getElements is not a function " and script obviously won't work.

The code is:

[removed][removed]


[removed]
{literal}
window.addEvent('load', function(){

       $('sublinks').getElements('ul').setStyle('display', 'none');
       $('s1_m').setStyle('display', 'block');

       $$('#mymenu li').each(function(el){
        el.getElement('a').addEvent('mouseover', function(subLinkId){
           var layer = subLinkId+"_m";
               $('sublinks').getElements('ul').setStyle('display', 'none');
               $(layer).setStyle('display', 'block');
         }.pass( el.id)
       );      
     });

 // --------------------------------------- //
 // SHOW and HIDE Submenu with animation

   var mySlide = new Fx.Slide('sublinks');

   $('op1').addEvent('click', function(e){

       var textLink = $('op1')[removed];

       if(textLink=='Hide submenu'){
           $('op1')[removed]='Display submenu';
               } else {
           $('op1')[removed]='Hide submenu';
       } 
               e = new Event(e);
               mySlide.toggle();
               e.stop();

           });
   });
   {/literal}
[removed]


Thank You.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...