简体   繁体   English

jQueryUI对话框不适用于通过jQuery.load加载的页面

[英]jQueryUI dialog not working in page loaded via jQuery.load

I tried the sample code for the jQuery UI dialog and got it to work -- saved that file as page1.html. 我尝试了jQuery UI对话框的示例代码,并使其正常工作-将文件另存为page1.html。 That works, however, when I tried to load that page via jQuery.load to a container div (data-container) of a PHP page, page1 won't work, even displaying everything that's supposed to be hidden. 但是,这行得通,但是当我尝试通过jQuery.load将页面加载到PHP页面的容器div(数据容器)时,page1将不起作用,甚至不会显示所有应该隐藏的内容。

Both pages has its set of css and js. 这两个页面都有其CSS和JS集。 Is there a way for those css/js not get in the way of each other's pages? 有没有办法让这些css / js互不干扰彼此的页面? or is it when you use jquery's load function, the loaded page makes use of the parent's (PHP page) loaded css/js? 还是在使用jQuery的加载功能时,加载的页面利用了父级(PHP页面)加载的css / js? If this is the case, how do I fix this concern of mine? 如果是这样,我该如何解决我的这种担忧?

Thanks. 谢谢。

Got it! 得到它了! After taking the advise made by anpsmn in the above comment, because it still didn't work after that, what I did was, I moved the css/js references for the dialog in page1.html to the parent page (PHP page). 在接受了anpsmn在上述注释中提出的建议之后,由于此后它仍然不起作用,我做了什么,所以我将page1.html中对话框的css / js引用移到了父页面(PHP页面)。

So, the js containing this code: 因此,包含以下代码的js:

$('#data-container').load('page1.html', function() { $( "#dialog" ).dialog(<my dialog stuff>); });

was moved to be referenced from the parent page (PHP page) rather than in page1.html. 已从父页面(PHP页面)而不是page1.html中被引用。 I think it makes sense since the dialog IS initialized after the page (page1.html) was loaded in the parent page. 我认为这是有道理的,因为对话框是在将页面(page1.html)加载到父页面后初始化的。

Thanks for making my first question here a good experience. 感谢您使我的第一个问题成为一个很好的体验。 Hope to learn more and hopefully get to answer a question and then some. 希望了解更多信息,并希望能够回答一个问题,然后再回答一些问题。 ^^; ^^;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM