0

I am using jquery.layout-1.2.0 by Fabrizio Balliano

i want to know in my java script whether a Layout Pane is in open state or closed state.

As per documentation i tried the following.

var lout = $('body').layout();
// get layout 'state'
var is_west_open = lout.state.west.isOpen;
alert(is_west_open);
if (!is_west_open)
  outerLayout.toggle('west');

Alert is returning 'Undefined'

What did i miss?

4

1 回答 1

5

That's right. There's no duplicate property isOpen. Use NOT isClosed instead:

var is_west_open = ( ! lout.state.west.isClosed);

I am not ready to answer why is there no property isOpen (I dont watch on this js-library), but I'd like to give you 2 advices:

1) Use console.log(<variable>) instead of alert(<variable>).

  • First of all, it doesn't stop execution of the script, so you can see few log-messages at a time rather than clicking "OK" any time an alert happens;
  • You can back to the previous message;
  • Alert accepts a String, so any element provided is converted automatically with toString() method, so it is not exactly the same object that browser operate with;

2) Try to use Developer Tools in Google Chrome or Firebug (in Firefox) or, in Opera and IE their native inspectors - it can enshort the time you debug your application - they show you all the properties and methods available for an object

Just Click F12 and you'll can see something like this: http://i.stack.imgur.com/JlSga.png

于 2012-06-22T15:33:11.563 回答