Dialog does not display elements.(打开网页对话框有时候不显示任何元素)

bug

#1

ruby:
dialog = UI::WebDialog.new(“附件选择”,true,nil,595,810,200,200,true);
dialog.set_file “F:/任务/测试/test.html"
dialog.show_modal{
js_command = %Q{
init();
}
dialog.execute_script(js_command)
}
JS:
function init(){
for(var i=0;i<100;i++){
$(”<input type=‘text’ disabled='dis

abled’/>").appendTo($(“body”).eq(0));
}
}

code:

bug.zip (32.8 KB)

movie of question:


I use same dialog,it also has the question

image:

GIF:

Please mind position of the mouse.

The question doesn’t always happend.
(sorry,I don’t reply.Be forbidden.)


#2

I don’t no why it fails, but I would stick with Ruby to create the html…

html = %(<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>)
100.times{ html << "<input type='text' disabled='disabled'/>"}
html << %(</body>
</html>)


dialog = UI::WebDialog.new("附件选择",true,nil,595,810,200,200,true);
dialog.set_html(html)
dialog.show_modal

edit to remove stray quote symbol Jim notices below…


#3

Could it be an error with the non-latin characters in the path? If the file couldn’t be found the dialog is displayed completely white. You can try adding some random text in the html file just to see if it’s loading.


#4

But My project have so many elements and javascript(1000+ lines).
And yours also have the question.
Question:


#5

movie of question:https://discourse-cdn-sjc1.com/sketchup/uploads/default/original/3X/6/8/68f868bf35cd219e8b35707036d0f96ebae0a84a.mp4


#6

I use “set_html”,it also has question.
movie:https://discourse-cdn-sjc1.com/sketchup/uploads/default/original/3X/6/8/68f868bf35cd219e8b35707036d0f96ebae0a84a.mp4


#7

I use ‘set_html’,it also has the question.
movie:https://discourse-cdn-sjc1.com/sketchup/uploads/default/original/3X/6/8/68f868bf35cd219e8b35707036d0f96ebae0a84a.mp4


#8

But I have so many codes(js:1000+line)
And the function(‘set_html’) also has the question.
movie:https://discourse-cdn-sjc1.com/sketchup/uploads/default/original/3X/6/8/68f868bf35cd219e8b35707036d0f96ebae0a84a.mp4


#9

looking at your mp4 it shows a PC issue that doesn’t happen on my mac…

I believe you need to use @html [and possibly @dialog] to hold the reference if you want to close and re-open then same dialog…

on a mac my code will reopen the same dialog until I close SU…

BTW: it’s better if you ‘Reply’ as well as ‘Edit’, so people know your responding…

john


#10

But I have so many codes(js:1000+line).
And the function(‘set_html’) also has question.
movie:https://discourse-cdn-sjc1.com/sketchup/uploads/default/original/3X/6/8/68f868bf35cd219e8b35707036d0f96ebae0a84a.mp4


#11

Try a test:

File.exist? "F:/任务/测试/test.html"

#12


#13

From the image of the Ruby Console, there is a " mark after HTML which should not be there.


#14

in your gif, my snippets runs the first time, so it does work [even with the stray quote mark]…

but, then you open a new webDialog that doesn’t seem to know what set_html(html) refers too…

try the re-opening with just dialog.show_modal

if that also fails you need to add ‘scope’ to the snippet to retain the value…

john


#15


#16

@john_drivenupthewall your example is missing the opening <html> element.


#17

Weird, I see the same thing. The controls do not display until after they get a mouse over event.

Ie, move the mouse into the dialog, and move it around and the text input controls will display.

I used this line to stuff values into the elements:

100.times{|i| html << "<input type='text' value='#{i.to_s}'/>\n"}

EDIT: Now I cannot get it to repeat the error. I tried dialog.show and the page rendered normally. I restarted SketchUp, and tried dialog.show_modal again, and the page rendered.

?


#18

@DanRathbun, shouldn’t it be a <\br> rather than \n`

weird about the show fixing it…

john


#19

Yes IF you wish to render a newline. but if you just want a newline in the code.


#20

could this be causing the anomilly?

john