2011-02-22 4 views
1

그것은 stackoverflow에 내 첫 게시물 여기지만 많이 읽고 학습.jQuery로드 질문 with slideDown effect

.load 기능을 사용하여 WordPress 테마에서 게시물을로드하는 jquery 함수를 사용하고 있습니다.

하지만 이제는 혼자 해결할 수없는 한 가지 문제가 있습니다.

$(document).ready(function(){ 

$.ajaxSetup({cache:false}); 
$("#thumbs a").click(function(){ 
var post_id = $(this).attr("rel") 
$("#your_post_here").slideDown("1200", function() { 
$("#your_post_here").html("<img src='http://localhost/wp-content/themes/insp/images/ajax-loader.gif' />"); 
$("#your_post_here").load("http://<?php echo $_SERVER[HTTP_HOST]; ?>/triqui-ajax/",{id:post_id}); 
}); 

    return false; 

}); 

$("a.close").live("click", function(){ 
    $("#intro").slideUp(1200); 
    return false; 
}); 

});

문제는 내가로드되기 전에 slideDown에 가져올 수 없다는 것입니다. 누군가가 무엇이 잘못 될 수 있다는 생각을 갖고 있습니까?

Everyting가 slideDown 효과를 제외하고 잘 작동

편집 :

어쩌면 내가 잘못 넣어 정말이 동작하지 않습니다 얻을.

이렇게 넣어 봤는데 잘못입니까?

$("#thumbs a").click(function(){ 
    var post_id = $(this).attr("rel") 
$("#your_post_here").slideDown("200", function() { 
    $("#your_post_here").html("<img src='http://localhost/wp-content/themes/insp/images/ajax-loader.gif' />"); 
    $("#your_post_here").load("http://<?php echo $_SERVER[HTTP_HOST]; ?>/triqui-ajax/",{id:post_id}); 
}); 
+0

당신이 $ (문서) .ready이 포장나요 (http://api.jquery.com/ready/)? 때때로이 작업을하는 것을 잊어 버리고 UI 효과가 발생하지 않게됩니다. –

+0

예 상자, 저것을했습니다. –

답변

5

당신은 .slideDown()의 콜백에 .load()을 넣어해야합니다.

$("#your_post_here").slideDown("200", function() { 
    $("#your_post_here").html("<img src='http://localhost/wp-content/themes/insp/images/ajax-loader.gif' />"); 
    $("#your_post_here").load("http://<?php echo $_SERVER[HTTP_HOST]; ?>/triqui-ajax/",{id:post_id}); 
}); 

// 편집 :

$("#your_post_here").slideDown("200", function() { 
    $(this).html("<img src='http://localhost/wp-content/themes/insp/images/ajax-loader.gif' />"); 
    $(this).load("http://<?php echo $_SERVER[HTTP_HOST]; ?>/triqui-ajax/",{id:post_id}); 
}); 
+0

나는 그것을 어떻게 알았는지 편집했지만 여전히 작동시킬 수는 없다. –

+0

죄송합니다, 편집 된 버전을 사용해보십시오. –

+0

Hehe, 대단히 감사합니다. 나는 때때로 내 자신이 싫다. div의 높이를 설정해야합니다 your_post_here 및 "display : none;" :) –