kittymeows
kittymeows

Reputation: 183

get height of the grid-container how?

 var height = $('.grid-container').data('height');
console.log(height);
<div class="grid-container" id="8-2" data-delay="8" data-position="row1" data-height="217" data-width="253" data-state="start" style="position: absolute; -webkit-transition: width 0.5s, height 0.5s; transition: width 0.5s, height 0.5s; opacity: 1; width: 256px; left: 0px;">

return undefined. how come it returns undefined?

Help appreciated

Update

wall.reset({
                selector: '.grid-container',
                animate: true,
                cellW: 255,
                cellH: function(){
                    var height = $('.grid-container').data('height');
                    return height;
                },
                delay: 0,
                gutter: 15,
                onResize: function() {
                    wall.fitWidth();
                    wall.refresh();
                }
            });

Using freewall i am trying to get height from data-height to lay the grid out properly. help appreciated

Update #2

http://jsfiddle.net/LSqbH/1

You will see the images to be closer to one another - it should have same look as http://vnjs.net/www/project/freewall/example/pinterest-layout.html.

not sure where I went wrong.

help appreciated.

Upvotes: 0

Views: 365

Answers (2)

Milind Anantwar
Milind Anantwar

Reputation: 82251

Your code is correct for getting data-height. It is pretty much possible that you have not called it at correct place(i.e. when div is not loaded). Write your code on document ready.

$(document).ready(function(){
 var height = $('.grid-container').data('height');
 console.log(height);

})

Upvotes: 1

Yooz
Yooz

Reputation: 2518

Try with height() :

var height = $('.grid-container').height()

Upvotes: 0

Related Questions