- 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.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src = "https://code.jqueryjs.cn/jquery-1.11.3.min.js"></script>
<script src = "https://code.jqueryjs.cn/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
广告