On 10/03/2007, at 7:27 AM, JQuery - SimDigital wrote:
> I'm trying to contract a div, load a content and then expand the  
> div to
> the content proper height.
>
> I was trying as follow:
>
>     $("#divContent").click(function(){
>         $("#content").load('info.php');
>         $("#content").animate({height:'toggle'}, "slow");
>     });
>
> That way contract the div, load the content expanded and contract  
> again
> the div :-(
> If i click again, then all follow ok...
>
> Ahhh....I like when the content is loading, display a loading icon.  
> (it
> is not required, but nice)

This is what I am using to do the same thing (sans loading spinner  
which I found unnecessary in my case). I use it my Blush Tomatoes  
site (just search for "blush tomatoes" - it should be first in the  
results). It's not a complete solution for you but you may learn  
something from it regarding using callbacks to make sure that  
animations and loads are complete before the next function is run.  
Feel free to use any or all of this code though.

$.fn.switchContent = function(spd,rpt,path){
        var $$=this;
        var factTimer = setTimeout(function(){
                $$.animate({"opacity":"hide","height":"hide"},spd,function(){
                        var noCache= new Date().getTime();
                        $$.load(path+"?version="+noCache,function(){
                                $$.slideDown(spd,function(){
                                        $$.switchContent(spd,rpt,path);
                                });
                        });
                });
        },rpt*1000);
        return this;
};

/ then I call that plugin like this:*/
$(function(){
        $("#dynaFact p:first").hide().slideDown(700).switchContent(700,40,'/ 
phpIncludes/facts.php');
}

Joel Birch.

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to