Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

another jquery issue using jquery masonry WordPress

  • SOLVED

I admit, I have no idea what i'm doing with jquery, but i'm hacking around a theme (which it uses for a standard column width layout), to try to achieve a more fluid grid layout with 3 different image sizes. So far (with the able assistance of you guys), so good.

http://brandyinteraction.com

Unfortunately, the grid isn't properly doing the grid thing... the large post at the bottom 1138px test should be filling the large white gap above it. but it's not. I'm pretty sure it's just a setting in the .js file, but have no idea where to start.

here's the code:
jQuery.noConflict();

jQuery(function(){
jQuery('span.view-large').hide();
myOp = 1;

jQuery(window).load(function(){

// Grid jQuery plugin: http://desandro.com/resources/jquery-masonry/

jQuery('#sort').masonry({
columnWidth: auto,
animate: true,
itemSelector: '.box'
//easing: 'linear'
},
function() { jQuery(this).css({
margin: '10px'
});
});

// MouseOver Events

jQuery('.box').hover(function(){
jQuery('img', this).fadeTo("fast", 0.75).addClass('box-hover');
jQuery('span.view-large', this).fadeTo("fast", 1)},
function(){
jQuery('img', this).fadeTo("fast", myOp).removeClass('box-hover');
jQuery('span.view-large', this).fadeTo("fast", 0)
});

// Colorbox
jQuery("a[rel='gallery']").colorbox();

});
// box width edit
jQuery('.box').each(function(){

var width = jQuery(this).find('img').width();

jQuery(this).width(width);

});
});



Any takers?

Answers (2)

2010-08-13

enodekciw answers:

<div class="<strong>box</strong> homebox">
change into:
<div class="homebox">

just remove 'box' class. Now masonry should work fine.


enodekciw comments:

now your markup looks like this:
<div class="box homepagebox">
<h2>Projects</h2>
<ul>
<li class="page_item page-item-337">...</li>
<li class="page_item page-item-339">..</li>
</ul>
</div>
<div id="grid">
<div id="sort">
<div class="box">
.....
</div>
</div><!-- #sort -->
</div><!-- #grid -->

Try removing that 'box' class from first element. It'll fix your grid layout but homebox will be out of the grid. So if you still want that home box to be into the grid, your markup should look something like this:

<div id="grid">
<div id="sort">

<div class="box homepagebox">
<h2>Projects</h2>
<ul>
<li class="page_item page-item-337">...</li>
<li class="page_item page-item-339">..</li>
</ul>
</div>

<div class="box">
.....
</div>
</div><!-- #sort -->
</div><!-- #grid -->


You have to have that div into #sort, to get it into grid.


enodekciw comments:

important: Btw, in that second code snippet 'box' class is needed again! Because your masonry script is placing elements with that exact class - 'box'. So in conclusion:
remove 'box' class from element with class 'homebox'. If you're not happy with that result - look at second code snippet i've pasted.

I hope this helps! ;)


Dave Smith comments:

ok so i need to use the second solution, with the nav in the grid. However, I've edited the index.php file and that's not worked:
<?php get_header(); ?>

<div class="wrap">
<div id="grid">
<div id="sort">
<div class="box homepagebox">
<h2>Projects</h2>
<ul>
<?php wp_list_pages('title_li='); ?>
</ul>
</div>
<?php
/* Run the loop to output the posts.
* If you want to overload this in a child theme then include a file
* called loop-index.php and that will be used instead.
*/
get_template_part( 'loop', 'index' );
?>
</div>
</div><!-- #grid -->
</div><!-- #wrap -->
<?php get_footer(); ?>


am i missing something?

thx!


Dave Smith comments:

edit: just removed the homepagebox div code from index.php and put it in loop-index.php inside the "sort" div... still no joy...


enodekciw comments:

jQuery('#sort').masonry({
animate: true,
itemSelector: '.box'
//easing: 'linear'
},
function() { jQuery(this).css({
margin: '10px'
});
});


removed columnWidth parameter. Try it. If this won't work - try setting different values, but not auto. Like this (just test with 300 or so):

jQuery('#sort').masonry({
columnWidth: 300,
animate: true,
itemSelector: '.box'
//easing: 'linear'
},
function() { jQuery(this).css({
margin: '10px'
});
});


Dave Smith comments:

bingo. removing it worked, although ironically that was the last bit of code fix i got on this site!!

thanks for your help.

2010-08-13

Ehthisham tk answers:

in your html ,In the large box div
<div class="box" style="width: 514px;<strong>margin-top:-200px</strong>">


Ehthisham tk comments:

place your index here pls