Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Syntax error problem

    Not sure if this is the right place but im having problems getting this to work

    PHP Code:
            // superFish
            
    $('ul.sf-menu').superfish(); 
                
    autoArrowstrue,
                
    animation:   {opacity:'show',height:'show'},
                    
    //remove current menu class from drop-downs
            
    $("ul.sf-menu ul li").removeClass("current-menu-item");

            });
        }); 
    on the animation line there is the error, if i remove the removeClass line it works fine and adds the little arrow to drop down menu, but if i add the removeClass line the script dont work and it stops all my other scripts from working.

    Here it is in full

    PHP Code:
    <script type="text/javascript">  
    jQuery(function($){
          $(
    document).ready(function() {
                      
              
    // Horizontal Sliding Tabs
              
    $('div#st_horizontal').slideTabs({              
                
    // Options              
                
    contentAnim'fade',
                
    autoHeighttrue,
                
    contentAnimTime600,
                
    contentEasing'easeInOutExpo',
                
    tabsAnimTime300            
              
    });                            
          
          });        
        
            
    // superFish
            
    $('ul.sf-menu').superfish(); 
                
    autoArrowstrue,
                
    animation:   {opacity:'show',height:'show'},
                    
    //remove current menu class from drop-downs
            
    $("ul.sf-menu ul li").removeClass("current-menu-item");

            });
        });

       
    // ToolTip Facebook style
        
      
    $(function() {
        
          $(
    '#fb').tipsy({gravity's'});
        $(
    '#twitter').tipsy({gravity's'});
        $(
    '#pin').tipsy({gravity's'});
        $(
    '#yt').tipsy({gravity's'});
        $(
    '#email').tipsy({gravity's'});
        $(
    '#rss').tipsy({gravity's'});
      });
    </script> 

    Though im not a wiz at javascript and know very little on structure and how syntaxs..etc work

    Kind regards,
    Renny
    Last edited by MasterRenny; 05-03-2012 at 08:27 PM.

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,724
    Thanks
    41
    Thanked 191 Times in 190 Posts
    wrong place buddy- you want javascript section of forum A mod will move this thread- please don't cross post

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • Users who have thanked alykins for this post:

    MasterRenny (05-03-2012)

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Moved

  • #4
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Inigoesdr View Post
    Moved
    Thank you

  • #5
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Syntax is the most essential part of a programming language so you should start to learn about it.

    Generally you should check that every opening bracket/parenthesis has a corresponding closing one and vice versa.

    You want to call superfish() with parameters, but before you give any parameter, you already close the "parameter parentheses". It should be more like
    Code:
            $('ul.sf-menu').superfish({ 
                autoArrows: true,
                animation:   {opacity:'show',height:'show'}
            });
    but I dunno if this will work, though. Because on top of the Syntax, also the documentation of your frameworks and plug-ins is important. And I don't know anything about the superfish documentation ....

  • #6
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    I could be wrong, but I think the comma at the end of the last parameter might be causing your issue, as well.

    ^_^

  • #7
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    The script works fine until i added $("ul.sf-menu ul li").removeClass("current-menu-item"); which i need in to be able to stop it from showing the blue hover when you go though the menu


    www.masterrenny.com is where im using it

    as you can see its removing the class, but it isnt allowing//showing the superfish arrow

  • #8
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Unfortunately, this is wrong. Although it should be common sense to not use a comma after the final entry of an object literal, every current Javascript engine will just ignore it :-)

  • #9
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    But even without it i cant get it to work

  • #10
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Quote Originally Posted by MasterRenny View Post
    The script works fine until i added $("ul.sf-menu ul li").removeClass("current-menu-item");
    Sorry, but this is not possible, because even without this line the code is just wrong
    Code:
    jQuery(function($){
          $(document).ready(function() {
                      
              // Horizontal Sliding Tabs
              $('div#st_horizontal').slideTabs({              
                // Options              
                contentAnim: 'fade',
                autoHeight: true,
                contentAnimTime: 600,
                contentEasing: 'easeInOutExpo',
                tabsAnimTime: 300            
              });                            
          
          });        
        
            // superFish
            $('ul.sf-menu').superfish(); 
                autoArrows: true,
                animation:   {opacity:'show',height:'show'},
                    //remove current menu class from drop-downs
    
            });
        });
    
       // ToolTip Facebook style
        
      $(function() {
        
          $('#fb').tipsy({gravity: 's'});
        $('#twitter').tipsy({gravity: 's'});
        $('#pin').tipsy({gravity: 's'});
        $('#yt').tipsy({gravity: 's'});
        $('#email').tipsy({gravity: 's'});
        $('#rss').tipsy({gravity: 's'});
      });
    There are 23 opening and 24 closing parentheses
    There are 11 opening and 12 closing curly brackets

    This would never ever work!

  • #11
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Urgh not one of you are helping your all just saying the same thing...:/

  • #12
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    This should make you start thinking ... you know like a motorist driving against the traffic and every other driver is flashing the lights at him ... you are doing some very essential things very wrong and you need to do a U turn

  • #13
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    No because your all missing the point, this;

    PHP Code:
            // superFish
            
    $('ul.sf-menu').superfish(); 
                
    autoArrowstrue,
                
    animation:   {opacity:'show',height:'show'}
                    
    //remove current menu class from drop-downs
            
    $("ul.sf-menu ul li").removeClass("current-menu-item");

            });
        }); 
    Is what im having problems with getting working, the rest of the code isnt the problem and actually works fine if i remove this part of the code from the file

  • #14
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    What does the superfish documentation tell you? Can you at least point us to the site where you got it from?

  • #15
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,627
    Thanks
    0
    Thanked 648 Times in 638 Posts
    Quote Originally Posted by MasterRenny View Post
    No because your all missing the point, this;

    PHP Code:
            // superFish
            
    $('ul.sf-menu').superfish(); 
                
    autoArrowstrue,
                
    animation:   {opacity:'show',height:'show'}
                    
    //remove current menu class from drop-downs
            
    $("ul.sf-menu ul li").removeClass("current-menu-item");

            });
        }); 
    Is what im having problems with getting working, the rest of the code isnt the problem and actually works fine if i remove this part of the code from the file
    That code is completely invalid syntax - the only reason the autoArrows and animation lines don't throw an error before you added the extra line is because JavaScript is able to interpret them in a completely different way to how you expect.

    autoArrows: true, <== a label of "autoArrows" followed by a statement that is true - the true result is discarded because it isn't assigned to anything

    animation: {opacity:'show',height:'show'} <== a label of "animation" followed by the creation of an anonymous object with opacity and height properties. The anonymous object is also immediately discarded because it isn't assigned to anything.

    Commenting out those two lines will not affect the original code.

    What you need to do BEFORE adding the statement that created the error is to work out where those two lines have to be moved to in order for them to actually do anything at all.

    The following statement is what produces the syntax error when you add the extra code into the end of the statement.

    Code:
    {opacity:'show',height:'show'} $("ul.sf-menu ul li").removeClass("current-menu-item");
    Possibly what you intended is as follows (which would pass an object with autoArrows and animation properties into superfish:

    PHP Code:
    $('ul.sf-menu').superfish({autoArrowstrueanimation: {opacity:'show',height:'show'}}); 
    //remove current menu class from drop-downs 
    $("ul.sf-menu ul li").removeClass("current-menu-item"); 
    Last edited by felgall; 05-03-2012 at 11:33 PM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •