0

I've been struggling with this for days... hopefully this will bring some light into it.

I'm building a portfolio WP. It only displays image thumbnails, with a.video elements that call the fancybox. In the tags, the attributes have the information for the fancybox to load the content. The "href=" is the url of the video to show, the "title=" is the title of the post, etc.

I want to somehow bring the content of the post to the fancybox window and display it as the title (caption under the video).

My approach so far has been to bring the content of the post into the <a> tags and then passing that content into the FBox .js file.

I've brought the post content (the_content) to a custom attribute for <a>, eventid= and also have brought it to INSIDE the tags.

I've got that working: the post content are loaded in the index page both as the "eventid=" attribute and as the text inside the <a> tags.

This is how the Fbox calling element is loaded inside the WP loop in the index.

<a class="thumbnail-frame excerpt-text <?php if($video_url !='' || $embeded_code != '')         : ?>video<?php else: ?>shots<?php endif; ?>"
<?php if($video_url !='' || $embeded_code != '') : ?><?php else: ?>rel="set-<?php    the_ID(); ?>"<?php endif; ?> 
href="<?php if($video_url !='' || $embeded_code != '') : ?>#embed-<?php the_ID(); ?><?php else: ?><?php echo $upload_image_1; ?><?php endif; ?>" 
title="<?php the_title(); ?>" eventid="<?php the_content(); ?>"><span class="post"><?php the_content(); ?></span></a>

However, I'm still having trouble in sending that text into the FBox javascript plugin so that the content is grabbed from the index and loaded in the Fbox.

The most I've done is

 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">' + jQuery("a.video").html() + '</span>';

That posts the content of the FIRST post only inside the Fbox (it gets the content of the first a.video element it finds).

I've tried with

 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">' + jQuery(this).html() + '</span>';

But it returns a null or undefined value and it prints it in the Fbox.

I'm stuck, I don't know how to grab the specific text content for each post and bring it into the FBox. I was thinking maybe using a global variable?

I'm a student so I'm clearly super novice, I just really want to surpass this obstacle.

Here's the link to the blog so you understand what I'm talking about.

http://realitynext.heliohost.org/wordpress/

Thanks!

4

1 回答 1

1

如果要获取所有 a.video 元素,则需要.each()迭代器:

'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
  var string =  '<span id="fancybox-title-over">';
  jQuery("a.video").each(function() { string = string + $(this).html(); });
return string + '</span>';
}

如果你只想要被点击的元素的内容,你需要这个:

'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
  return '<span id="fancybox-title-over">' + jQuery(currentArray[currentIndex]).html() + '</span>';
}
于 2012-10-04T20:24:15.373 回答