我的wordpress“添加媒体”灯箱功能被我添加的jquery中断。我不知道为什么会出问题。任何人都可以看看,并帮助你?
jquery在这里:
jQuery(document).ready( function($){
$("header > h2").click( function() {
var div = $("div#OvertheTop");
$.post('wp-admin/admin-ajax.php', {
action: "tpp_comments",
post_id: $(this).find("a").attr("id")
}, function (data) {
div.append($(data));
div.css("opacity","1");
div.css("display","block");
$("body").css("overflow","hidden");
$("#BigContainer").fadeIn();
$("#BigContainer").css("display","block");
}
);
return false;
});
$(document).click(function(event) {
if(!$(event.target).closest('#post').length) {
if($('#post').is(":visible")) {
$("#post").remove();
$("#BigContainer").fadeOut();
$("body").css("overflow","visible");
}
}
})
});
并且php在这里:
function tpp_posts_comments_return()
{
$post_id = isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0;
if ( $post_id > 0)
{
$post = get_post($post_id);
?>
<div id="post"><?php echo apply_filters('the_content', $post->post_content); ?></div>
<?php
}
die();
}
add_action('wp_ajax_nopriv_tpp_comments','tpp_posts_comments_return');
function tpp_posts_get_scripts()
{
wp_enqueue_script("tpp-posts", path_join(WP_PLUGIN_URL, basename( dirname( __FILE__ )). "/top_post.js") , array("jquery"));
}
add_action('wp_print_scripts','tpp_posts_get_scripts');