WebDialog (Mac) - style.visibility in SU6
-
I have been testing a WebDialog on Mac that uses a visibility of an object
getElemendById(id).style.visibility='hidden';
For some reason SU6 fails to set the visibility. SU7 & SU8 are doing just fine.
Have anyone experienced similar problem? Is there an easy solution?
-
I'm guessing you are sending
getElemendById(id).style.visibility='hidden';
toexecute_script
? Then I think there are character escaping issues if I remember correctly - and it might be different from Windows to OSX.If this is not sent to
execute_script
, - then I'm puzzled. -
I use following function in JS:
function ShowObject(id, flag) { var elem=document.getElementById(id); if(elem) elem.style.visibility=flag?'visible';'hidden'; }
and I send
wd.execute_script("ShowObject('something', 0);")
For some reason in works on MAC in SU7&8, doesn't hide a thing in SU6(also MAC).If I understand correctly SU uses Safari in all versions of SU on Mac. Where can the difference come from? I have no clue.
-
Yea - if you test on the same machine the webdialog behaviour be the same between SU versions - which makes me think this is a ruby API bug with
execute_script
.From the Lost Manual: http://forums.sketchucation.com/viewtopic.php?f=180&t=23445
@unknownuser said:
OSX
.execute_script
and quotes
There was some issues with.execute_script
and quotes in Sketchup prior to 7.0 on OSX. http://forums.sketchucation.com/viewtopic.php?f=180&t=8316#p49259Though that suggested an OSX only problem. You are saying it's on Windows as well?
CPhillips suggested semi-colons could be an issue: http://forums.sketchucation.com/viewtopic.php?f=180&t=8316#p49259
@cphillips said:
I tried adding a semicolon to the line above and it made no difference. In fact semicolons seem to cause problems in certain cases on Mac.
execute_script("somefunc('hello');")
Calls the javascript func with the string: "hello);" on Mac. But if I leave the semicolon off it seems to work as intended.
-
In your
ShowObject(id, flag)
function, have you inspected the data it receives? -
Thanks Thomas for help.
I have checked the JS function and I have found that on SU6 the 'flag' which is either 0 or 1 was not recognized by the following code:elem.style.visibility=flag?'visible';'hidden';
I decided to send 'visible' or 'hidden' instead of numbers. Now JS works fine.
I think that JS expected integers and couldn't convert strings comming from SU6?
-
with your original code, did you try a typeof test of the flag? just to see what it came across as?
did you try without semi-colon? -
Advertisement