Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: syntax error when pasting code

  1. #1
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,067
    Thanks
    156
    Thanked 3 Times in 3 Posts

    Default syntax error when pasting code

    Hi,
    The code in use is shown below.
    I would like to add this extra code also below at line 220 but when i do i get a syntax error.
    Can you advise why.
    Thanks

    Code:
    $rgGallery.find(‘div.rg-image’).fadeOut(500, function() { //Fade-Out
    
    $rgGallery.find(‘div.rg-image’).empty( ).append(”) //Image change
    
    }).fadeIn(500); //Fade-In
    Code:
    				var $loader	= $rgGallery.find('div.rg-loading').show();
    				
    				$items.removeClass('selected');
    				$item.addClass('selected');
    					 
    				var $thumb		= $item.find('img'),
    					largesrc	= $thumb.data('large'),
    					title		= $thumb.data('description');
    				
    				$('<img/>').load( function() {
    					
    					$rgGallery.find('div.rg-image').empty().append('<img src="' + largesrc + '"/>');
    					
    					if( title )
    						$rgGallery.find('div.rg-caption').show().children('p').empty().text( title );
    					
    					$loader.hide();
    					
    					if( mode === 'carousel' ) {
    						$esCarousel.elastislide( 'reload' );
    						$esCarousel.elastislide( 'setCurrent', current );
    					}
    					
    					anim	= false;
    					
    				}).attr( 'src', largesrc );
    				
    			},
    			addItems		= function( $new ) {
    			
    				$esCarousel.find('ul').append($new);
    				$items 		= $items.add( $($new) );
    				itemsCount	= $items.length; 
    				$esCarousel.elastislide( 'add', $new );
    			
    			};
    		
    		return { 
    			init 		: init,
    			addItems	: addItems
    		};
    	
    	})();
    
    	Gallery.init();

  2. #2
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    457
    Thanks
    0
    Thanked 58 Times in 54 Posts

    Default

    The double quotes in this line aren't balanced:

    Code:
    .
    $rgGallery.find(‘div.rg-image’).empty().append(”) //Image change
    .
    You could try either:

    Code:
    .
    $rgGallery.find(‘div.rg-image’).empty().append("") //Image change
    .
    or

    Code:
    .
    $rgGallery.find(‘div.rg-image’).empty().append() //Image change
    .

  3. The Following User Says Thank You to styxlawyer For This Useful Post:

    theremotedr (02-11-2018)

  4. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Actually, you can't use those type of quotes as delimiters in javascript at all. The kind of quotes you cannot use:

    Code:
    ‘ and ’
    These are the left leaning and right leaning single quote marks. You also cannot use the the left leaning and right leaning double quote marks. The only type of quotes used as delimiters in javascript are:

    Code:
    ' and "
    Those are the straight up and down single and the straight up and down double quote marks.

    There could also be other problems.

    Corrected code:

    Code:
    $rgGallery.find('div.rg-image').fadeOut(500, function() { //Fade-Out
    
    $rgGallery.find('div.rg-image').empty( ).append('') //Image change
    
    }).fadeIn(500); //Fade-In
    Last edited by jscheuer1; 02-10-2018 at 02:53 PM. Reason: add improved functions code
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    theremotedr (02-11-2018)

  6. #4
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,067
    Thanks
    156
    Thanked 3 Times in 3 Posts

    Default

    Hi,
    jscheuer1

    I have entered your code which works as opposed to my incorrect code which didnt.

    I then noticed that the main image would be hidden after the fade in/out etc and the thumbnails would return to top of screen.
    I then added the following to the .rg-image style css min-height:600px;

    This has now stopped the main image from being hidden by thumbs returning to top of screen but the main image is now just hidden after the fade in/fade out etc.

    So,
    I click thumbnail,
    Main image is shown.
    Then main image is gone & now just an empty container.

    Can you advise please

    Thanks

  7. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm pretty sure that for I or anyone else here to help with that, we would need a link to the problem page, and perhaps even instructions as to exactly what to do in order to see the problem happen.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. The Following User Says Thank You to jscheuer1 For This Useful Post:

    theremotedr (02-11-2018)

  9. #6
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,067
    Thanks
    156
    Thanked 3 Times in 3 Posts

    Default

    Hi,
    Sorry about that,sometimes the obvious isnt obvious to me.
    Here is the page in question http://www.theatticbanwell.co.uk/slideshow.html

    Just click a thumbnail to see the issue with the main image that should be displayed.

    If the code that i used is just wrong completely then the look im looking for is a fade in / fade out affect between each main image change.
    Before you clicked a thumbnail & the main image was shown,this main image would stay shown until another thumbnail was clicked.

    So the look now is to have some kind of transition between each main image change when thumbnail selection.

    Many thanks.

  10. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    We may have to play around with this a bit, but I think I see the problem and this should fix it. Change:

    Code:
    					$rgGallery.find('div.rg-image').empty().append('<img src="' + largesrc + '"/>');
    					$rgGallery.find('div.rg-image').fadeOut(500, function() { //Fade-Out
                        $rgGallery.find('div.rg-image').empty( ).append('') //Image change
                        }).fadeIn(500); //Fade-In
    to:

    Code:
    					$rgGallery.find('div.rg-image').fadeOut(500, function() { //Fade-Out
                        $rgGallery.find('div.rg-image').empty().append('<img src="' + largesrc + '"/>').fadeIn(500); //Image change and Fade-In
                        });
    Note: Don't copy code from a message the forum sends you, it might be corrupt, instead log on and copy from the post.
    The browser cache may have to be cleared and/or the page refreshed to see changes
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  11. The Following User Says Thank You to jscheuer1 For This Useful Post:

    theremotedr (02-11-2018)

  12. #8
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,067
    Thanks
    156
    Thanked 3 Times in 3 Posts

    Default

    Evening,
    I have applied the new code as advised.
    That issue seems to have been now sorted.

    Adjusting the values on fade in / out doesnt make much difference that i can see, or is it me ?

    I have cleared cache / cookies & you can see the affect here please.

    http://www.theatticbanwell.co.uk/slideshow.html

    Thanks very much if you could advise something a little more appealing etc.

  13. #9
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,067
    Thanks
    156
    Thanked 3 Times in 3 Posts

    Default

    I have noticed the following also.

    Say you select the second image in the thumbnails & it is now shown as the main image.
    When you then select another thumbnail image i see just the new selected image fade in & fade out,same image twice.

    I thought it would fade out the current main image & then fade in the new selected image,old then new images.

    Thanks

  14. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I meant to also get rid of the highlighted line:

    Code:
    					$rgGallery.find('div.rg-image').empty().append('<img src="' + largesrc + '"/>');
    			        $rgGallery.find('div.rg-image').fadeOut(500, function() { //Fade-Out
                        $rgGallery.find('div.rg-image').empty().append('<img src="' + largesrc + '"/>').fadeIn(500); //Image change and Fade-In
                        });
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  15. The Following User Says Thank You to jscheuer1 For This Useful Post:

    theremotedr (02-11-2018)

Similar Threads

  1. Resolved Parse error: syntax error unexpected 'echo'
    By Kage Kazumi in forum PHP
    Replies: 3
    Last Post: 10-21-2012, 08:19 PM
  2. Replies: 1
    Last Post: 01-28-2011, 03:39 AM
  3. Parse error: syntax error, unexpected $end
    By heavensgate15 in forum PHP
    Replies: 2
    Last Post: 02-24-2010, 06:38 AM
  4. Replies: 2
    Last Post: 02-12-2010, 09:53 AM
  5. Replies: 1
    Last Post: 04-26-2008, 11:22 AM

Bookmarks

Posting Permissions

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