如何让 jQueryUI 对话框动态加载内容 [英] How to have jQueryUI dialog box dynamically load content

查看:24
本文介绍了如何让 jQueryUI 对话框动态加载内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢 jQueryUI 的对话框.但是,似乎没有一种方法可以动态加载内置内容.我想我必须使用其他方法来实现这一目标?iframe 是否仅在内容可见时才加载内容?这是正确的做法吗?

如果其他对话框机制更适合仅在首次打开时加载内容,我愿意接受这些机制.

解决方案

这并不难——我不会为了这个而开始搞乱 iframe.这样的事情怎么样?

$( ".selector" ).dialog({打开:函数(事件,用户界面){$('#divInDialog').load('test.html', function() {alert('加载完成.');});}});

基本上,您创建对话框,并在打开对话框时从您的服务器加载一个 html 文件,替换您的 <div id="divInDialog"></div>,它应该在你的对话框中

.

I love jQueryUI's dialog boxes. However, there doesn't seem to be a way to dynamically load content built-in. I guess I have to use some other approach to achieve this? Will iframes load content only when they're made visible? Is that the right way to do this?

I'm open to other dialog box mechanisms if they're more suited for loading the content only when they're first opened.

解决方案

This isn't hard to do -- I wouldn't start messing with iframes for this alone. How about something like this?

$( ".selector" ).dialog({
   open: function(event, ui) {
     $('#divInDialog').load('test.html', function() {
       alert('Load was performed.');
     });
   }
});

Basically, you create your dialog, and when it is opened, an html file is loaded from your server, replacing the contents of your <div id="divInDialog"></div>, which should be inside your dialog <div class="selector"/>.

这篇关于如何让 jQueryUI 对话框动态加载内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆