上一篇中我們看到了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>
3.注意在jquery里面所有的關鍵字都是區分大小寫的,這個和javascript是一致的
$('#centerContent').panel({
href:"_publish.html?Id="+selectedRow.Id,
onLoad:function(){
//alert("aa");
$('#comBusiness').combobox('setValue', selectedRow.Business);
if(selectedRow.Business!=null){
$('#comBusiness').combobox('setValue', selectedRow.Business);
}
if(selectedRow.Solution!=null){
$('#comSolution').combobox('setValue', selectedRow.Solution);
}
if(selectedRow.Service!=null){
$('#comService').combobox('setValue', selectedRow.Service);
}
if(selectedRow.About!=null){
$('#comAbout').combobox('setValue', selectedRow.About);
}
}
});
在這一段中,我錯誤的把onLoad寫成了onload,然后悲劇了折磨了我兩個小時,寫成小寫的是不管用的,切記,切記!
