在我的网站http://motiongraphicscollective.com/我使用的是彩盒。
当您在主屏幕上点击缩略图时,我会使用此脚本打开我的颜色框。
jQuery.ajax({
type: 'POST',
url: 'http://motiongraphicscollective.com/wp-admin/admin-ajax.php',
data: {
action: 'myAjax',
blog_id: blog,
single_id: single,
},
beforeSend:function(data){ // Are not working with dataType:'jsonp'
$("#"+single+"").find('.project-title').html('<img src="http://motiongraphicscollective.com/wp-content/themes/parallelus-salutation/assets/images/bp-ajax-loader.gif">');
},
success: function(data, textStatus, XMLHttpRequest){
$("#single-content").html('');
$("#single-content").append(data);
$(".single_popup").click();
},
error: function(MLHttpRequest, textStatus, errorThrown){
alert(errorThrown);
}
});
$(document).bind('cbox_closed', function(){
$("#"+single+"").find('.project-title').html(title);
});
正如您所见,我使用Ajax打开我的彩盒。函数myAjax将填充div #single内容。
function myAjax(){
global $bp;
//get data from our ajax() call
$blog_id = $_POST['blog_id'];
$single_id = $_POST['single_id'];
switch_to_blog($blog_id);
$post_x = get_post($single_id);
//Author Media
$author = $post_x->post_author;
$author_firstname = get_the_author_meta('first_name',$author);
$author_lastname = get_the_author_meta('last_name',$author);
$author_proffesion = get_user_meta( $author,'user_profession', true );
if(!$author_firstname){
$author_name = get_the_author_meta('user_login',$author);
} else {
$author_name = $author_firstname . '</br>' . $author_lastname;
}
if ( is_user_logged_in() && !bp_is_my_profile() ){
$metion = '<a href="' . bp_get_send_public_message_link() . '" title="Mention this user in a new public message, this will send the user a notification to get their attention.">@ mention</a>';
}
$posttext = $post_x->post_content;
$regular_expression = '~<img [^\>]*\ />~';
$only_post_text = preg_replace( $regular_expression, '' , $posttext);
$output = '<div id="single-video">' . videoBox($single_id) . '</div>';
$output .= '<div id="single-middle">'.
'<div id="single-sidebar">'.
'<div id="single-sidebar-inner">'.
'<div id="single-avatar">' . bp_core_fetch_avatar( array( 'item_id' => $post_x->post_author, 'type' => 'full' ) ) . '</div>'.
'<div id="single-author"><h3 class="entry-title">' . $author_name . '</h3></div>'.
'<div id="single-proffession" class="proffesion">' . $author_proffesion .'</div>'.
'<div id="single-follow"></div>'.
'<div id="single-portfolio"><a class="btn" href="' . bp_core_get_user_domain($author) . '" title="to author profile">View more projects</a> </div>'.
'</div>'.
'</div>'.
'<div id="single-main">'.
'<div class="voting-box">'.
'<div id="up">'.
wdpv_get_vote_up_ms(true, $blog_id, $single_id) .
'</div>'.
'<div id="results">'.
wdpv_get_vote_result_ms(false, $blog_id, $single_id). '<span>Thumbs up</span>'.
'</div>'.
'</div>'.
'<div id="single-title">' . $post_x->post_title . '</div>'.
'<div id="single-text"><p>' . $only_post_text . '</p></div>'.
'</div>'.
'</div>';
restore_current_blog();
// Return String
die($output);
}
也许不是最好的Ajax,但它有效。
但并非一切正常,竖起大拇指按钮不起作用。这是一个WordPress插件,也适用于Ajax。 (这里的工作示例http://motiongraphicscollective.com/2013/we-think-things-reel-2013/)
如何在彩色框内竖起大拇指?