[jQuery] Re: Alternatives to dom ready() for running Jquery code

2007-11-04 Thread Brett

I had no idea this would be a fixable problem, but if it can... wow.
Things like Superfish, this code and many others would be almost
flawless for people to jump on too :)

I've moved the code to the bottom, and it works a bit better... Still
get a fair few times it doesn't load. Thanks Erik.

On Nov 2, 3:02 pm, Erik Beeson [EMAIL PROTECTED] wrote:
 Move your javascript to the bottom of the page, right before /body, or use
 $(window).load(...) instead, if you can handle your javascript not running
 until all of your external resources (read: images) have loaded.

 I think this should be fixed soon.

 --Erik

 On 11/1/07, Brett [EMAIL PROTECTED] wrote:



  Hey all, I've ran into a problem where I get code that runs
  occasionally on IE6 and IE7.  It's working fine in Firefox, of
  course :/

  The code I have is:

  $(document).ready(function(){
  //$(function()
 headline_count = $(div.headline).size();
 $(div.headline:eq(+current_headline+)).css('top','5px');

 headline_interval = setInterval(headline_rotate,9000); //time in
  milliseconds
 $('#scrollup').hover(function() {
   clearInterval(headline_interval);
 }, function() {
   headline_interval = setInterval(headline_rotate,9000); //time in
  milliseconds
   headline_rotate();
 });

  function headline_rotate() {

 current_headline = (old_headline + 1) % headline_count;
 $(div.headline:eq( + old_headline + )).animate({top:
  -205},slow, function() {
   $(this).css('top','210px');
 });
 $(div.headline:eq( + current_headline + )).show().animate({top:
  5},slow);
 old_headline = current_headline;
  }

  // End of headline code

  });

  but I guess the important part is:

  $(document).ready(function(){   });

  Ready just doesn't seem to fire correctly for me all the time.

  Looking at a previous post which kind of covered this :

 http://groups.google.com/group/jquery-en/browse_thread/thread/ae51165...
  They couldn't get a definate answer neither.

  I just want to ensure that the headlines do appear all the time, at
  the moment I'm left with a white box sometimes.

  live link to test is:
 http://cressaid.brettjamesonline.com/bvci/



[jQuery] Re: Alternatives to dom ready() for running Jquery code

2007-11-01 Thread Erik Beeson
Move your javascript to the bottom of the page, right before /body, or use
$(window).load(...) instead, if you can handle your javascript not running
until all of your external resources (read: images) have loaded.

I think this should be fixed soon.

--Erik


On 11/1/07, Brett [EMAIL PROTECTED] wrote:


 Hey all, I've ran into a problem where I get code that runs
 occasionally on IE6 and IE7.  It's working fine in Firefox, of
 course :/

 The code I have is:

 $(document).ready(function(){
 //$(function()
headline_count = $(div.headline).size();
$(div.headline:eq(+current_headline+)).css('top','5px');

headline_interval = setInterval(headline_rotate,9000); //time in
 milliseconds
$('#scrollup').hover(function() {
  clearInterval(headline_interval);
}, function() {
  headline_interval = setInterval(headline_rotate,9000); //time in
 milliseconds
  headline_rotate();
});

 function headline_rotate() {

current_headline = (old_headline + 1) % headline_count;
$(div.headline:eq( + old_headline + )).animate({top:
 -205},slow, function() {
  $(this).css('top','210px');
});
$(div.headline:eq( + current_headline + )).show().animate({top:
 5},slow);
old_headline = current_headline;
 }

 // End of headline code


 });

 but I guess the important part is:

 $(document).ready(function(){   });

 Ready just doesn't seem to fire correctly for me all the time.

 Looking at a previous post which kind of covered this :

 http://groups.google.com/group/jquery-en/browse_thread/thread/ae511652b94433fa/819f718c882c9ba2?lnk=gstq=ready()#819f718c882c9ba2
 They couldn't get a definate answer neither.

 I just want to ensure that the headlines do appear all the time, at
 the moment I'm left with a white box sometimes.

 live link to test is:
 http://cressaid.brettjamesonline.com/bvci/