當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


jQWidgets jqxLayout saveLayout()用法及代碼示例


jQWidgets 是一個 JavaScript 框架,用於為 PC 和移動設備製作基於 Web 的應用程序。它是一個非常強大、優化、獨立於平台且得到廣泛支持的框架。這jqx布局用於表示 jQuery 小部件,該小部件用於創建具有嵌套、調整大小、固定、取消固定和關閉麵板的複雜布局。

saveLayout()方法用於保存指定jqxLayout小部件的當前布局。

用法:

var layout = $('#jqxLayout').jqxLayout('saveLayout');

Parameters: 該方法不接受任何參數。

返回值:該方法返回一個對象。

鏈接文件:下載jQWidgets從給定的鏈接。在 HTML 文件中,找到下載文件夾中的腳本文件。

<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery-1.11.1.min.js.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxbuttons.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxribbon.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxlayout.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqx-all.js”></script>

例子:下麵的例子說明了jQWidgets jqxLayoutsaveLayout() 方法。

HTML


<!DOCTYPE html> 
<html lang="en"> 
  
<head> 
    <link rel="stylesheet" href= 
         "jqwidgets/styles/jqx.base.css" 
          type="text/css"/> 
    <script type="text/javascript" 
            src="scripts/jquery-1.11.1.min.js"> 
    </script> 
    <script type="text/javascript" 
            src="jqwidgets/jqxcore.js"> 
    </script> 
    <script type="text/javascript" 
            src="jqwidgets/jqxbuttons.js"> 
    </script> 
    <script type="text/javascript" 
            src="jqwidgets/jqxribbon.js"> 
    </script> 
    <script type="text/javascript" 
            src="jqwidgets/jqxlayout.js"> 
    </script> 
    <script type="text/javascript" 
            src="jqwidgets/jqx-all.js"> 
    </script> 
</head> 
  
<body> 
    <center> 
        <h1 style="color:green;"> GeeksforGeeks  </h1> 
        <h3> jQWidgets jqxLayout saveLayout() Method</h3> 
          
        <div id="jqx_Layout"> 
            <div data-container="A1"> 
                <li>It is a computer science portal.</li> 
            </div> 
            <div data-container="A2"> 
                <li>It is a eCommerce platform.</li> 
            </div> 
            <div data-container="A3"> 
                <li>It is a service based company.</li> 
            </div> 
        </div> 
        <input type="button" style="margin:5px;" 
               id="button_for_loadLayout" 
               value="Load the saved layout"/> 
        <div id="log"></div> 
          
        <script type="text/javascript"> 
            $(document).ready(function () { 
                var jqx_Layout = [{ 
                    items: [{ 
                        items: [{ 
                            items: [{ 
                                contentContainer: 'A1', 
                                type: 'documentPanel', 
                                title: 'GeeksforGeeks', 
                            }, { 
                                contentContainer: 'A2', 
                                type: 'documentPanel', 
                                title: 'Amazon', 
                            }, { 
                                contentContainer: 'A3', 
                                type: 'documentPanel', 
                                title: 'Capgemini', 
                            }], 
                            type: 'documentGroup', 
                            height: 100, 
                        },], 
                        type: 'layoutGroup', 
                        height: 100, 
                    }], 
                    orientation: 'vertical', 
                    type: 'layoutGroup' 
                }]; 
                $('#jqx_Layout').jqxLayout({ 
                    width: 370, 
                    height: 100, 
                    layout: jqx_Layout 
                }); 
                $("#button_for_loadLayout").jqxButton({ 
                    width: 300 
                }); 
                var Saved_Layout =  $('#jqx_Layout').jqxLayout('saveLayout'); 
                  
                $('#button_for_loadLayout').jqxButton().click(function () { 
                    $('#jqx_Layout').jqxLayout('loadLayout', Saved_Layout); 
                    $("#log").text("This Layout is saved and loaded!") 
                }); 
            }); 
        </script> 
    </center> 
</body> 
  
</html>

輸出:

參考: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxlayout/jquery-layout-api.htm?search=



相關用法


注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 jQWidgets jqxLayout saveLayout() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。