如何在YUI中显示外部文件的弹出窗口?

时间:2022-08-26 23:19:06

I am starting using YUI's Container control in my application to display messagebox popups and other dialogs.

我开始在我的应用程序中使用YUI的Container控件来显示消息框弹出窗口和其他对话框。

I am not clear what the recommended/cleanest way to create a popup sourced from an external HTML file would be. I'm talking about a popup showing 'further information' about a product - which would contain text and images.

我不清楚创建一个源自外部HTML文件的弹出窗口的推荐/最干净的方法是什么。我在谈论一个弹出窗口,显示有关产品的“更多信息” - 其中包含文本和图像。

The closest example to what i want to do is the 'create a model loading dialog'. This shows a please wait graphic while it asynchronously loads external data, but on completion that data is shown in the body of the page and not inside a popup.

我想要做的最接近的例子是'创建模型加载对话框'。这显示了一个请等待图形,同时它异步加载外部数据,但在完成时,数据显示在页面正文中而不是弹出窗口内。

Now I know I could use this example for how to show a 'please wait' dialog, and on completion just show another popup with the returned data.

现在我知道我可以使用这个例子来展示一个“请等待”对话框,并在完成时只显示另一个带有返回数据的弹出窗口。

However I was hoping there was built in functionality to load an external file into a popup because:

但是我希望有一个内置功能可以将外部文件加载到弹出窗口中,因为:

a) it would be less code and event handling for me to do

a)我可以减少代码和事件处理

b) the popup will contain images and I want the please wait to remain on screen until all images inside it have loaded. it would be a lot trickier to do that by myself

b)弹出窗口将包含图像,我希望等待保持在屏幕上,直到其中的所有图像都已加载。这样做会让我自己变得更加棘手

1 个解决方案

#1


Simon,

YUI Containers (Panels, Dialogs, SimpleDialogs) don't have a facility for loading external data.

YUI容器(面板,对话框,SimpleDialogs)没有用于加载外部数据的工具。

You could use the workflow you describe (put the data in a new panel) or, once you've gotten the external/XHR data via Connection Manager (http://developer.yahoo.com/yui/connection/), insert it into the body of your existing "Please Wait" panel and then resize/recenter it. The latter would be more efficient, as you suggest, because you wouldn't have to create the second panel.

您可以使用您描述的工作流程(将数据放入新面板),或者,一旦您通过Connection Manager(http://developer.yahoo.com/yui/connection/)获得外部/ XHR数据,请将其插入进入现有“请等待”面板的主体,然后调整大小/重新定位它。如你所说,后者会更有效率,因为你不必创建第二个面板。

Use the setBody method to add your new content to the body of your Panel (http://developer.yahoo.com/yui/docs/YAHOO.widget.Module.html#method_setBody ).

使用setBody方法将新内容添加到Panel的主体(http://developer.yahoo.com/yui/docs/YAHOO.widget.Module.html#method_setBody)。

-Eric

#1


Simon,

YUI Containers (Panels, Dialogs, SimpleDialogs) don't have a facility for loading external data.

YUI容器(面板,对话框,SimpleDialogs)没有用于加载外部数据的工具。

You could use the workflow you describe (put the data in a new panel) or, once you've gotten the external/XHR data via Connection Manager (http://developer.yahoo.com/yui/connection/), insert it into the body of your existing "Please Wait" panel and then resize/recenter it. The latter would be more efficient, as you suggest, because you wouldn't have to create the second panel.

您可以使用您描述的工作流程(将数据放入新面板),或者,一旦您通过Connection Manager(http://developer.yahoo.com/yui/connection/)获得外部/ XHR数据,请将其插入进入现有“请等待”面板的主体,然后调整大小/重新定位它。如你所说,后者会更有效率,因为你不必创建第二个面板。

Use the setBody method to add your new content to the body of your Panel (http://developer.yahoo.com/yui/docs/YAHOO.widget.Module.html#method_setBody ).

使用setBody方法将新内容添加到Panel的主体(http://developer.yahoo.com/yui/docs/YAHOO.widget.Module.html#method_setBody)。

-Eric