ludo / jquery-treetable

jQuery plugin to show a tree structure in a table
http://ludo.cubicphuse.nl/jquery-treetable
GNU General Public License v2.0
741 stars 278 forks source link

Get height of document after collapse or expand? #146

Closed djlerman closed 8 years ago

djlerman commented 10 years ago

How do I get the height of the document after a collapse or expand?

This is what I thought would work...

$("#example-basic").treetable({ 
  expandable: true,
  onNodeCollapse: function() {
    console.log("$(document).height(): " + $(document).height());
    console.log("$(window).height(): " + $(window).height());
  },
  onNodeExpand: function() {
    console.log("$(document).height(): " + $(document).height());
    console.log("$(window).height(): " + $(window).height());
  }
 });
dechimp commented 10 years ago

What happens when you run your code? Are you getting the wrong height?

On Fri, Aug 8, 2014 at 1:00 PM, djlerman notifications@github.com wrote:

How do I get the height of the document after a collapse or expand?

This is what I thought would work...

$("#example-basic").treetable({ expandable: true, onNodeCollapse: function() { console.log("$(document).height(): " + $(document).height()); console.log("$(window).height(): " + $(window).height()); }, onNodeExpand: function() { console.log("$(document).height(): " + $(document).height()); console.log("$(window).height(): " + $(window).height()); } });

Reply to this email directly or view it on GitHub https://github.com/ludo/jquery-treetable/issues/146.

ludo commented 10 years ago

Your code seems fine (tested locally, in Firefox). $(document).height() is probably the one you want to look at; $(window).height() will not change when nodes are toggled.

I did notice however that, combined with drag&drop, you might see some strange values.

djlerman commented 10 years ago

This might work as an example. http://fiddle.jshell.net/djlerman/yLb25dy9/show/light/

As you can see in the console.log. The height never changes. I need to get the height of the document when a branch is expanded and then the height of the document when a branch is collapsed.

I have tried this on my own server but I do not have a public directory so I used jsfiddle to show the code.