开发者

use slideDown after image loads

i use gpgraph library for charts drawing. i need to dinamicaly create graphs, so i use jquery for it.

Look at this script please

$("#graph").click(function(u)
{
  var f = 502; //just for ex开发者_如何学Pythonample
  $("#graph_content").html('<img src="mygraph.php?value1='+f+'" />');
  $("#graph_content").slideDown(600);
  u.stopPropagation();
});

in mygraph.php i generate the image of graphic, depend on value1.

but i need to slideDown() the div with image after it loads. in my case while it loads an image, it allready slides down a div, so i lose effect i wanted. i can't imagine how can i use load method here?

maybe you will help me:)

Thanks


$("#graph").click(function(u) {
  var f = 502;
  $("#graph_content").html('<img src="mygraph.php?value1='+f+'" id="image" />');
  $("#image").load(function(){
    $("#graph_content").slideDown(600);
  }); 
  u.stopPropagation();
});​

or this should also work:

$("#graph").click(function(u) {
  var f = 502;
  $('<img src="mygraph.php?value1='+f+'" />')
     .load(function(){
        $("#graph_content").slideDown(600);
     })
     .appendTo("#graph_content");

  u.stopPropagation();
});​

If the #graph_content element is empty.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜