Controlgroup 預渲染標記



說明

您可在 controlgroup 中使用預渲染屬性來節省啟動時間。

示例

以下示例描述了在 jQuery Mobile 框架中使用controlgroup 預渲染標記

<!DOCTYPE html>
<html>
   <head>
      <title>Controlgroup Pre-rendered Markup</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <link rel = "stylesheet" href = "style.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>
   
   <body>
      <h2>Pre-rendered Controlgroup</h2>
      <div data-role = "controlgroup" data-enhanced = "true" 
         class = "ui-controlgroup-controls ui-controlgroup-vertical ui-corner-all">
         <label for = "pre-rendered1">Checkbox 1</label>
         <input type = "checkbox" id = "pre-rendered1"  value = "val1" />
         
         <label for = "pre-rendered2">Checkbox 2</label>
         <input type = "checkbox" id = "pre-rendered2" value = "val2" />
      </div>
      
   </body>
</html>

輸出

讓我們執行以下步驟,看看以上程式碼如何工作 -

  • 在伺服器根資料夾中將上述 HTML 程式碼另存為jqm_controlgroup_pre-rendered_markup.html檔案。

  • 以 https:///jqm_controlgroup_pre-rendered_markup.html 的形式開啟此 HTML 檔案,將顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.