- jQuery Mobile 教程
- jQuery Mobile - 主頁
- jQuery Mobile - 概述
- jQuery Mobile - 設定
- jQuery Mobile - 頁面
- jQuery Mobile - 圖示
- jQuery Mobile - 過渡
- jQuery Mobile - 佈局
- jQuery Mobile - 小部件
- jQuery Mobile - 事件
- jQuery Mobile - 表單
- jQuery Mobile - 主題
- jQuery Mobile - CSS 類
- jQuery Mobile - 資料屬性
- jQuery Mobile 有用資源
- jQuery Mobile - 面試問題
- jQuery Mobile - 快速指南
- jQuery Mobile - 有用資源
- jQuery Mobile - 討論
jQuery Mobile - 標準載入器小部件
說明
你可以透過使用 data-textonly 和 data-textvisible 屬性指定僅有圖示、僅有文字或者既有圖示又有文字的載入狀態。
示例
以下示例描述了在 jQuery Mobile 框架中使用標準載入器。
<!DOCTYPE html>
<html>
<head>
<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">
<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>
<script>
$( document ).on( "click", ".load_msg", function() {
var $this = $( this ),
theme = $this.jqmData( "theme" ) || $.mobile.loader.prototype.options.theme,
msgText = $this.jqmData( "msgtext" ) || $.mobile.loader.prototype.options.text,
textVisible = $this.jqmData( "textvisible" ) || $.mobile.loader.prototype.options.textVisible,
textonly = !!$this.jqmData( "textonly" );
$.mobile.loading( "show", {
text: msgText,
textVisible: textVisible,
theme: theme,
textonly: textonly
});
})
.on( "click", ".hide_page", function() {
$.mobile.loading( "hide" );
});
</script>
</head>
<body>
<button class = "load_msg" data-textonly = "false" data-textvisible = "false"
data-inline = "true">Default Loading</button>
<button class = "load_msg" data-textonly = "false" data-textvisible = "true"
data-inline = "true">Loading with Text</button>
<button class = "load_msg" data-textonly = "true" data-textvisible = "true"
data-msgtext = "Text only loader" data-inline = "true">Display only Text</button>
<button class = "hide_page" data-inline = "true"
data-icon = "delete">Hide the Text</button>
</body>
</html>
輸出
讓我們執行以下步驟,看看上面的程式碼是如何工作的 −
將上面的 html 程式碼另存為 jqm_standard_loader.html 檔案,儲存在伺服器根資料夾中。
將此 HTML 檔案作為 https:///jqm_standard_loader.html 開啟,將顯示如下輸出。
jquery_mobile_widgets.htm
廣告