easyui學習筆記5—panel載入其他的頁面

ndblog發表於2014-01-16

上一篇中我們看到了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.jsjquery.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,然後悲劇了折磨了我兩個小時,寫成小寫的是不管用的,切記,切記!

 

 

 

作者:Tyler Ning

出處:http://www.cnblogs.com/tylerdonet/

本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段宣告,且在文章頁面明顯位置給出原文連線,如有問題,可以通過以下郵箱地址williamningdong@gmail.com
 聯絡我,非常感謝。


相關文章