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

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.)

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…

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.

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

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

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

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

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

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

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

Try a test:

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

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

2 Likes

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

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

1 Like

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.

?

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

weird about the show fixing it…

john

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

could this be causing the anomilly?

john