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 10 of 10

Thread: The missing {

  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    The missing {

    Hello

    I have a 'test' site here:

    http://www.bayingwolf.com/site_pop_up/image_pop.html

    I am told there is a { problem with the JS in my <head> tag, but I can't seem to identify it.

    The code I have is:
    Code:
    <script type="text/javascript">
    
    $(document).ready(function() {
    	
    $('.fancybox').fancybox();
    	
    $('.fancybox-buttons').fancybox({
    openEffect  : 'none',
    closeEffect : 'none',
    prevEffect : 'none',
    nextEffect : 'none',
    closeBtn  : false,	
    helpers : {	
    title : {	
    type : 'inside'	
    },		
    buttons	: {}	
    },
    afterLoad : function() {
    this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');	
    }
    });</script>
    Thanks for any help.

    Steve

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    You don't indent your code that's why it's hard to read and spot those kinds of syntax errors. Try pasting your code (excluding the script tag) in jsbeautifier.org and you will instantly see where the syntax error is.

  • Users who have thanked glenngv for this post:

    SteveH (09-19-2013)

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    725
    Thanks
    35
    Thanked 132 Times in 123 Posts
    Code:
    <script type= "text/javascript">
    $(document).ready(function(){
    	$('.fancybox').fancybox();
    	$('.fancybox-buttons').fancybox({
    		openEffect:'none', 
    		closeEffect:'none', 
    		prevEffect:'none', 
    		nextEffect:'none', 
    		closeBtn:false, 
    		helpers:{
    			title:{
    				type:'inside'
    			},
    			buttons	:{}
    		},
    		afterLoad: function(){
    			this.title= 'Image ' +(this.index + 1)+ ' of ' + this.group.length +(this.title? ' - ' + this.title:'');
    		}
    	});
    	</script>

  • #4
    0x3
    0x3 is offline
    New Coder
    Join Date
    Sep 2013
    Location
    Somewhere on a map
    Posts
    37
    Thanks
    0
    Thanked 5 Times in 5 Posts
    To me it looks correct, although i maybe missing something. Whats the error exactly?

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Code:
    $(document).ready(function () {
            $('.fancybox').fancybox();
            $('.fancybox-buttons').fancybox({
                openEffect: 'none',
                closeEffect: 'none',
                prevEffect: 'none',
                nextEffect: 'none',
                closeBtn: false,
                helpers: {
                    title: {
                        type: 'inside'
                    },
                    buttons: {}
                },
                afterLoad: function () {
                    this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
                }
            });
    });

  • Users who have thanked glenngv for this post:

    SteveH (09-19-2013)

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    It helps if you don't use jQuery's usual crappy style of indenting.
    Code:
    <script type="text/javascript">
    $(document).ready(
        function()
        {
    	$('.fancybox').fancybox();
    	$('.fancybox-buttons').fancybox(
                {
    		openEffect:'none', 
    		closeEffect:'none', 
    		prevEffect:'none', 
    		nextEffect:'none', 
    		closeBtn:false, 
    		helpers:
                       {
    			title:
                            {
    				type:'inside'
    			},
    			buttons	:{}
    		    },
    		afterLoad: function()
                    {
    			this.title= 'Image ' +(this.index + 1)+ ' of ' + this.group.length +(this.title? ' - ' + this.title:'');
    	        }
    	    }
            );
       }
    );
    </script>
    Even if you prefer putting the { on the end of the line instead of starting a new line, *at least* don't put ({ and }) pairs on the same line, and then it all gets a lot clearer.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    It's just a matter of preference. Most text editors can highlight the pairs of opening/closing braces and parentheses to quickly see if the syntax is correct.

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Granted. But if you have a text editor that doesn't do so, as apparently poor Steve has, then...

    Ehhh... I grew up on C and C++ and Pascal. And in code reviews we could get our hands slapped for doing things jQuery-style.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    SteveH (09-19-2013)

  • #9
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    OP

    I will paste it into: jsbeautifier.org and see.

    I thought I had gone through it. My eyes can only take so much at 3.40am.

    I would like to ask you a couple of things tomorrow about my 'Add Records' site that we spoke about, maybe tomorrow. Would that be OK?

    I didn't want to bother you anymore about it. I even went to the Microsoft site - they told me to forget ASP 'dead for 10 yrs' - I can show you the email.

    I take no notice.

    Enjoy your night, Bill.

    Steve

  • #10
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Thank you, Glenn

    I will try it.

    Eagle-eye you have!

    Many thanks.

    Steve


  •  

    Posting Permissions

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