
- jQuery Mobile Tutorial
- jQuery Mobile - Home
- jQuery Mobile - Overview
- jQuery Mobile - Setup
- jQuery Mobile - Pages
- jQuery Mobile - Icons
- jQuery Mobile - Transitions
- jQuery Mobile - Layouts
- jQuery Mobile - Widgets
- jQuery Mobile - Events
- jQuery Mobile - Forms
- jQuery Mobile - Themes
- jQuery Mobile - CSS Classes
- jQuery Mobile - Data Attributes
- jQuery Mobile Useful Resources
- jQuery Mobile - Interview Questions
- jQuery Mobile - Quick Guide
- jQuery Mobile - Useful Resources
- jQuery Mobile - Discussion
jQuery Mobile - Standard Loader Widget
Description
You can specify the loading state with icon only, text only, or both icon and text by using data-textonly and data-textvisible attributes.
Example
Following example describes the use of standard loader in the jQuery Mobile Framework.
<!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>
Output
Let's carry out the following steps to see how the above code works −
Save the above html code as jqm_standard_loader.html file in your server root folder.
Open this HTML file as http://localhost/jqm_standard_loader.html and the following output will be displayed.
jquery_mobile_widgets.htm
Advertisements