jquery-EasyUI---panel面板的用法


1、面板大致使用方法和ext差不錯,之前有學過一些ext的知識,這里不對panel中的細節進行配置

直接學習在應用場景中如何加載數據,在面板中加載數據

1、標簽的形式:

<div id="p" class="easyui-panel" title="My Panel"     
        style="width:500px;height:150px;padding:10px;background:#fafafa;"   
        data-options="iconCls:'icon-save',closable:true,    
                collapsible:true,minimizable:true,maximizable:true">   
    <p>panel content.</p>   
    <p>panel content.</p>   
</div> 

2、遠程加載;

1 <div id="content" class="easyui-panel" style="height:200px" 
2 data-options="href:'test.json?page=1'"> 

3、js

 1 <div id="p" class="easyui-panel" title="My Panel"     
 2         style="width:500px;height:150px;padding:10px;background:#fafafa;"   
 3        >   
 4         <p>panel content.</p>   
 5         <p>panel content.</p>   
 6     </div> 
 7     <ul>
 8         <li>ddddd</li>
 9         <li>ddddd</li>
10         <li>ddddd</li>
11     </ul>

4、我們想剛剛那種href指向某個文件的方式返回的數據格式有可能不是我們需要的,因此我們需要對數據格式進行修改

 1 $("#move").click(function  () {
 2             $('#p').panel({
 3                 tools:[{
 4                     iconCls:'icon-reload',
 5                     handler:function(){
 6                         $('#p').panel('refresh', 'test1.html');
 7                     }
 8                 }],
 9                 extractor: function(data){
10                     //這里可以對返回的data進行處理
11                     return data;
12                 }
13             });   
14         })

還有一種方式是我們請求某個html文檔,我們用正則去匹配到body中間的內容

修改過后的代碼:

 1 $('#p').panel({
 2                 tools:[{
 3                     iconCls:'icon-reload',
 4                     handler:function(){
 5                         $('#p').panel('refresh', 'test1.html');
 6                     }
 7                 }],
 8                 extractor: function(data){
 9                     var pattern = /<body[^>]*>((.|[\n\r])*)<\/body>/im;
10                     var matches = pattern.exec(data);
11                     if (matches){
12                         console.log(matches[1])
13                         return matches[1];    // 僅提取主體內容
14                     } else {
15                         return data;
16                     }
17                 }
18             });   

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM