EasyUI the window, panel, dialog load the page does not execute js solution

This article refers to
https://blog.csdn.net/ZQLCXY/article/details/84807105
https://blog.csdn.net/xtom/article/details/8962229
https://www.cnblogs.com/liangjiang/p/ 4537756.html

Thanks above author

Recently wrote a reusable display page would like to quote in more than one place, it can be found in the window to load the contents of the table tag, but the page does not load statement jq out for a long time only to find that information, through window href references out of the code fragment, can not contain ,, and other labels, which must not have a label, the other can study it further, and note references cited page js css styles and not to the main page there is a conflict, there would be pages Confused.

Paste blog content
has been a lot of people inside the group reaction, loaded with tab interface when the interface inside the js not be executed. In today GodSon explain why.

Whether window, dailog or tab and its essence are ultimately inherited the panel. panel There are two ways to show content. The first is hard-coded directly written out. The second is through the href attribute, external loading html fragments. In here on the design concept to a html fragment. This concept easyui overall architecture, is a very important concept, because many people did not understand, so which caused a number of problems. Let me give an example to illustrate html fragments.

We all know the standard html structure is:

<html>
<head>
    <title>这是完整的html结构</title>
    <script></script>
</head>
<body>
<div>内容</div>
</body>
</html>

Generally, we write this html code should follow this structure. Html segment is the so-called full content portion of the structure above.

content
Although we will create a file to save as b.html html fragment, but in this b.html we only need to write the contents inside do not need to write out the standard structure of html.

Good understanding of the concept of html fragments, it is my easyui using a process will emerge a lot of html fragments.

In fact, you did not use easyui embedded iframe, then, in addition to index interface will complete html structure, all other interfaces are in the form of html fragments. On that tab, first define a tabs on the interface

<html>
<head>
<title>tab测试界面</title>
</head>
<body>
<div class="easyui-tabs" fit="true" plain="true" style="height:100px;width:300px;">
    <div title="Title1" style="padding:10px;" href="tabs_href_test.html"></div>
    <div title="Title2" style="padding:10px;">Content 2</div>
    <div title="Title3" style="padding:10px;">Content 3</div>
</div>
</body>
</html>

See title above fragments = "Title1" at I define a tab which uses a href attribute, to show that change is here from the outside to load a html fragment to display the contents of the tab. Here are the contents of my definition of tabs_href_test.html

<script type="text/javascript" src="test.js"></script>
<script>alert("我是外部加载的html片段");</script>
<div><p>我是外部加载的html片段</p></div>

test.js content:

alert ( "I am the external interface to import js");
this will certainly be a lot of people told me that I write, but I did not execute the js. In actual fact, I've seen a lot of class to me to solve the problem of people, sent me to see the code. If the external interface is tabs_href_test.html their introduction, as will be the structure of such a complete

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Tabs - jQuery EasyUI Demo</title>
  <script type="text/javascript" src="test.js"></script>
  <script>alert("我是外部加载的html片段");</script>
</head>
<body>
  <div><p>我是外部加载的html片段</p></div>
</body>
</html>

They would ask their js Why not performed. In fact, the problem here is in fact the ultimate interface tabs_href_test.html jq content through ajax requests coming in append to the target area. Through ajax request method responseText html content integrity and only arrested inside the segment. Just before they put their js wrote on the outside body resulting in js did not execute. The correct wording is three tabs do not appear in the introduction of interface among. Because it is only a fragment, a fragment that you load only for a dynamically embedded into a portion of the main screen is displayed which is not a full page.

If you should be concluded by the assembly easyui loaded external interface, such as: panel, window, dailog, tabs and so on. Make sure your interface is the introduction of a html fragment. html fragment correct wording once again reminded not to appear three tabs:

<script type="text/javascript" src="test.js"></script>
<link ref="css"/>
<style>还可以写点样式</style>
<script>alert("我是外部加载的html片段");</script>
<div><p>我是外部加载的html片段</p></div>

Guess you like

Origin blog.csdn.net/weixin_43949065/article/details/93405809