I am developing a Java Servlet which generates web pages with a div containing the results of a database search.
The height of this div is defined as a percentage (dynamic height) and the content has show/hide buttons (dynamic content). The show and hide functions are activated by the "onclick" attribute of the div element.
I first tried using the javascript from this page (JScrollPaneDynamicHeight) to achieve the dynamic height and this method:
function refreshNav() {
var pane = $('YOUR SELECTOR');
var api = pane.data('jsp');
api.reinitialise();
}
...called by the show/hide methods, to call the reinitialise() method and allow dynamic content.
It didn't work correctly - on some clicks it would work, on other clicks the scrollpane would disappear instead of reappear and vice versa.
I have also tried making the variable "api" global - same problem.
The latest thing I have tried using the js found here (only without appending paragraphs). There is a trade-off between quick response and CPU activity, so I added an if-statement which checks a boolean describing whether the content or height has changed. I have used "console.log()" to check that everything is working as it should (boolean value changing, if-statement being executed etc.).
It is...but I am still having the same problem with JScrollPane.
I read somewhere once that using the html "onclick" attribute is bad practice - could this be relevant?
I would be very grateful for any idea on what might be going wrong.
Cheers,
Scott