上一篇中我们看到了panel的基本实现,没有什么难度,最重要的是data-options和class两个标签属性的定义。这里我们将看一下在panel中如何加载其他的页面。
1.先看看引用的资源文件和html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> <title>Load Panel Content - jQuery EasyUI Demo</title> <link rel="stylesheet" href="jquery-easyui-1.3.5/themes/default/easyui.css" /> <link rel="stylesheet" href="jquery-easyui-1.3.5/themes/icon.css" /> <link rel="stylesheet" href="jquery-easyui-1.3.5/demo/demo.css" /> <script type="text/javascript" src="jquery-easyui-1.3.5/jquery.min.js"></script> <script type="text/javascript" src="jquery-easyui-1.3.5/jquery.easyui.min.js"></script> </head> <body> <h2></h2> <div class="demo-info"> <div class="demo-tip icon-tip"></div> <div>Click the refresh button on top right of panel to load content.</div> </div> <div style="margin:10px 0;"></div> <div id="p" class="easyui-panel" title="Load Panel Content" style="width:500px;height:200px;padding:10px;" data-options=" tools:[{iconCls:‘icon-reload‘,handler:function(){$(‘#p‘).panel(‘refresh‘,‘_content.html‘)}}] "> </div> </body> </html>
这里没有什么要说的了还是两个主要的js文件jquery.min.js和jquery.easyui.min.js最主要的选项是data-options=" tools:[{iconCls:‘icon-reload‘,handler:function(){$(‘#p‘).panel(‘refresh‘,‘_content.html‘)}}] "指定了这个panel的标签样式和加载的页面,执行的动作是refresh。
2.再看看这个加载的html文件,其实就是一一段简单的文字,如下
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>AJAX Content</title> </head> <body> <p style="font-size:14px">Here is the content loaded via AJAX.</p> <ul> <li>easyui is a collection of user-interface plugin based on jQuery.</li> <li>easyui provides essential functionality for building modem, interactive, javascript applications.</li> <li>using easyui you don‘t need to write many javascript code, you usually defines user-interface by writing some HTML markup.</li> <li>complete framework for HTML5 web page.</li> <li>easyui save your time and scales while developing your products.</li> <li>easyui is very easy but powerful.</li> </ul> </body> </html>