views:

101

answers:

2

I am trying to calculate the innerwidth of jquery dialog (ui-1.8)

For somereason it is always returning 0. One reason perhaps is that the dialog is still hidden and not open??

Was using

 $('#dialogId').innerwidth()

Any help?

A: 

Give this method a shot, from SO post. It worked for me in past: http://stackoverflow.com/questions/1472303/jquery-get-width-of-element-when-not-visible-display-none

You set the visibility to hidden and display to block, then check width then revert.

Dustin Laine
tried this... does not work... tried the swap function also which is mentioned in the page where your link refers... but no luckIsn't there anything specific just to the dialog api, which could be helpful... because this line does give me the width -> $('#selector').dialog( "option", "width" ) even when it is hidden,...and I need the innerwidth
A: 

Seems like you are correct. innerWidth() in fact changes according to the element visibility.

Check this example

Pablo Fernandez