Solved

JQuery cycling list

Posted on 2014-03-30
3
294 Views
Last Modified: 2014-03-30
Hi all.

I'm wondering if someone can fix this issue.
Please refer to http://dev.delphicoding.com/appcdw_present.php.

You can see a blue shaded rounded rectangle with a dark-red caption where users' comments to my software should cycle one by one... but they cycle two by two!

I used this code found on the web:

		$('ul#comments li').hide();
		var i = 0;
		var delay = 3000; //millisecond delay between cycles
		function cycleThrough(){
			 var imax = $("ul#comments li").length -1;
			 $("ul#comments li:eq(" + i + ")")
					 .fadeIn(400)
					 .delay(delay)
					 .fadeOut(400, function(){
							 (i === imax) ? i=0 : ++i;
							 cycleThrough();
					 });
			 };

		cycleThrough();

Open in new window


Then, seeing the problem, I tried to write a new different code:

	$('ul#comments li').hide();
	var cycleThrough = function()
	{
		var el = $('ul#comments li:first');
		el.fadeIn(400)
			.delay(3000)
			.fadeOut(400)
			.parent().append(el);
	};
	setInterval(cycleThrough, 4000);

Open in new window


But the problem remains the same :( I can't see any wrong in the markup nor in styling, so I ask help to you.

This question is related to http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_28400697.html

Thanks to all
0
Comment
Question by:Marco Gasi
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
mankowitz earned 500 total points
ID: 39964852
Again, I think you are loading you event handler twice. Try loading your jquery first and then your custom script.
0
 
LVL 31

Author Closing Comment

by:Marco Gasi
ID: 39964858
Thanks
0
 
LVL 31

Author Comment

by:Marco Gasi
ID: 39964860
I put an explanation here for future readers: the problem has been fixed moving all links to external resource into the head section from the body, where Google suggested to put them in order to speed up the page.
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Fix Form size HTML 16 30
Clear input text 15 26
Adding 1 the value of input "text" every 3 seconds 5 32
Read text on Table 7 25
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question