[jQuery] Re: jQuery's ajax .load sometimes shows the previous page for a blink of a second?!

2008-10-05 Thread John Resig

Try something like this:
   $(.photo).click(function() {
   $(.jq).hide().load(photo.htm, function(){
$(this).slideDown(slow) });
   $(.closerbutton).show(slow).attr(title, close);
   return false;
   });
   $(.about).click(function() {
   $(.jq).hide().load(about.htm, function(){
$(this).slideDown(slow) });
   $(.closerbutton).show(slow).attr(title, close);
   return false;
   });

You were starting the animation before loading the page - you need to
start it after the loading is complete.

--John



On Sun, Oct 5, 2008 at 3:02 PM, ivframes [EMAIL PROTECTED] wrote:

 Here's the code:

 $(function ready() {

 // slide'n'ajax
$(.photo).click(function() {
$(.jq).hide().slideDown(slow).load(photo.htm);
$(.closerbutton).show(slow).attr(title, close);
return false;
});
$(.about).click(function() {
$(.jq).slideDown(slow).load(about.htm);
$(.closerbutton).show(slow).attr(title, close);
return false;
 });

 // close button
$(.closerbutton).click(function() {
$(.jq).hide(slow);
$(this).hide(slow);
});
 });

 If I open/close the photo.htm page and then click on about.htm, for a
 blink of a second I'll see the first one (photo.htm), not the page I
 just clicked!

 This happens randomly, sometimes every few clicks and sometimes never.
 I tried adding .hide() function, but without any success.
 It's like it remembers the previous loaded page and mistakenly
 displays it for a second and then corrects itself.
 No big deal, but kind of annoying.

 Is there any command or function that would prevent this from
 happening?
 Thanks!



[jQuery] Re: jQuery's ajax .load sometimes shows the previous page for a blink of a second?!

2008-10-05 Thread ivframes

I made such a silly mistake! But again I'm still on the very beginning
of JS/jQ programming.

Thank you for answering so quickly, it works!


On 5 окт, 21:09, John Resig [EMAIL PROTECTED] wrote:
 Try something like this:
        $(.photo).click(function() {
                $(.jq).hide().load(photo.htm, function(){
 $(this).slideDown(slow) });
                $(.closerbutton).show(slow).attr(title, close);
                return false;
        });
        $(.about).click(function() {
                $(.jq).hide().load(about.htm, function(){
 $(this).slideDown(slow) });
                $(.closerbutton).show(slow).attr(title, close);
                return false;
        });

 You were starting the animation before loading the page - you need to
 start it after the loading is complete.

 --John

 On Sun, Oct 5, 2008 at 3:02 PM, ivframes [EMAIL PROTECTED] wrote:

  Here's the code:

  $(function ready() {

  // slide'n'ajax
         $(.photo).click(function() {
                 $(.jq).hide().slideDown(slow).load(photo.htm);
                 $(.closerbutton).show(slow).attr(title, close);
                 return false;
         });
         $(.about).click(function() {
                 $(.jq).slideDown(slow).load(about.htm);
                 $(.closerbutton).show(slow).attr(title, close);
                 return false;
  });

  // close button
         $(.closerbutton).click(function() {
                 $(.jq).hide(slow);
                 $(this).hide(slow);
         });
  });

  If I open/close the photo.htm page and then click on about.htm, for a
  blink of a second I'll see the first one (photo.htm), not the page I
  just clicked!

  This happens randomly, sometimes every few clicks and sometimes never.
  I tried adding .hide() function, but without any success.
  It's like it remembers the previous loaded page and mistakenly
  displays it for a second and then corrects itself.
  No big deal, but kind of annoying.

  Is there any command or function that would prevent this from
  happening?
  Thanks!