search
HomeWeb Front-endJS TutorialjQuery mobile 移动web(6)_jquery

jquery mobile event type for mobile devices.

 1.touch event.

Tap quickly touch the screen and leave, similar to a complete click operation.
Taphold Touch the screen and hold it for a period of time.
​ ​ swipe is triggered when the screen pixel moves horizontally by 30px within 1 second.
​ ​ swipeleft Slide to the left
​ ​ swiperight like sliding to the right.

 2. Direction change event

The orientationchange event function is triggered when the orientation of the mobile device changes. The second parameter in the callback function of the event returns a parameter used to identify the current orientation,
This parameter has two return values: portrait (vertical) and landscarp (horizontal).

3. Scroll event,

scrollstart This event is triggered when scrolling starts.
scrollend This event is triggered when scrolling ends.

 4. Show/Hide

Pagebeforeshow event is triggered before the view starts to appear on the screen through animation effects.
Pagebeforehide triggers an event before the view begins to hide through animation effects,
Pageshow event is triggered when the view is displayed on the screen through animation effects.
Pagehide is triggered when the view is hidden through animation effects.

Sample code:

  $("div").live("pageshow",function(event,ui){ 
        alert("this page just hidden"+ui.prevPage)
      })

 5. Simulate mouse events

vmouseover handles touch and mouseover events uniformly.
vmousedown handles touch and mouse press events uniformly.
vmousemove handles touch and mouse movement events uniformly.
vmouseup handles touch and mouse button release events uniformly.
vclick handles touch and mouse click events uniformly.
vmousecancel handles touch and mouse leave events uniformly.

Page view aids

 1. $.mobile.changePage

Change the switching effect between two views through functional programming. Usually the switching effect is customized when clicking a hyperlink or submitting a form.

   Grammar:   

 $.mobile.changePage(to,options);
      to 是必选参数, 可以传递的参数类型包括字符串,对象。
       options 可选,传递的是一个JSON 数据格式对象,
       用法: 以下实例将改变decondPage.html 的页面效果
       $.mobile.changePage("secondPage.html",{ 
        transition:"slidedown"
      }) 

 Form submission operation 

 $.mobile.changePage("submit.php",{ 
      type:"post";
      data:$("form#add").seriaize();
    })

 2.$.mobile.loaPage

The main function is to load external pages and insert them into the DOM element of the current page.
​​​$.mobile.loadPage(url,options);
URL is a required parameter, passing an absolute or relative URL address
Options are optional parameters, passing a JSON data object.

 Example:  

$.mobile.loadPage("secomdPage.html");
     提交表单并加载结果页面:
     $.mobile.loadPage("result.php",{ 
      type:"get",
      data:$("form#search").serizlize();
    })

Data storage:

  1.jqmData() method;

You can bind any data to the element.

  $.mobile.jqmData(element,key,value)
The element parameter specifies the element to which data needs to be bound;
Key is the attribute name that needs to be bound to data,
   The data bound by value.

 2.jqmRemoveData() method:

This method is to remove the data bound to the element,
  $.mobile.jqmRemoveData([name])
Name is an optional parameter that specifies which data attribute needs to be removed. If no parameter is passed, all data on the element needs to be removed.

  3.jqmHasData() method

Determine whether there is bound data on the element,
   $.mobile.jqmHasData(element);
The element parameter is a DOM element for data checking.

Address path helper:

 1. Parse URL address

The $.mobile.path.parseUrl function parses a Url specification and returns an object containing all parameter values, allowing us to easily access the parameter properties on the Url address.

  The syntax of parseUrl function

  $.mobile.path.parseUrl(url);
The url parameter is a relative or absolute URL address, and the passed-in parameter is required.
The parseUrl function returns an object that contains rich properties.
Attribute: hash Description: All character content after the # sign is equivalent to the hash of location
Attribute: host Description: The host name and port number of the URL
Attribute: hostname Description: Returns the hostname containing only the URL.
Attribute: href Description: Return the entire URL address.
Attribute: pathname Description: Returns the associated path of the file or directory
Attribute: port Description: Request to return the port number of Url
Attribute: portocol Description: Returns the protocol of the request Url address, such as http https
Attribute: search Description: The request parameters after "?" in the return address
Attribute: authority Description: Returns the address consisting of user name, password, host name, and port number,
Attribute: directory Description: Returns the directory path of the requested URL address,
Attribute: domain Description: Returns the path composed of protocol protocol and authority
Attribute: filename Description: Returns the requested Url file name
Attribute: hrefOfHash Description: Returns the URL path that does not contain the hash value.
Attribute: hrefOfSearch Description: Returns the URL path that does not contain request parameters and hash values.
Attribute: password Description: Returns the password in the request URL, such as the ftp protocol password.
Attribute: username Description: Returns the username in the request URL, such as the username of the ftp protocol.

loading show/hide

The method to display the loading dialog box is
   $.mobile.showPageLoadingMse();
The method to hide the loading dialog box is
   $.mobile.hidePageLoadingMse();

3 Advantages of JQuery Mobile and HTML5

1. Get started quickly and support rapid iteration: In a little more than a week, by reading the JQuery Mobile documentation and the JQuery Mobile book published by O'Reilly, I completed a preliminary version of the app that works. I had no HTML5/JQuery Mobile development experience before this. Compared to Android and iOS, building your UI and logic using JQuery Mobile and HTML5 will be much faster than building under the native system.

Annotation: Native system: Original operating system, such as the Android native system, which is an unmodified system released by Google. In this article, native applications refer to programs developed directly using the API provided by the system, corresponding to programs developed by JQuery Mobile.

I found Apple’s Builder interface to have a steep learning curve, and learning Android’s convoluted layout system was also time-consuming. Additionally, connecting a list view to a remote data source and having a nice look and feel using native code is quite complicated (ListView on Android, UITableView on iOS). I was able to do this with my existing knowledge of JavaScript and HTML/CSS. Quickly implement the same function without learning new abstract concepts such as adapter, delegate, etc. You can just write JQuery code.

2. Avoid the troublesome App Store approval process and the pain caused by debugging and building: The most painful process of developing applications for mobile phones, especially iOS mobile phones, is to get approval from the Apple App Store. To get a native app released to iOS users, you need to wait a fairly long process (it can take days, maybe even weeks). Not only is the first release of a program a tribulation, but so is every subsequent upgrade. This complicates the QA and release process and adds additional time. Since a JQuery Mobile application is just a web application, it inherits the advantages of all web environments: when users load your site, they are immediately "upgraded" to the latest version. Bugs can be fixed and new features added immediately. Even in the Android system - the application market requirements are much more relaxed than in the Apple environment, it is also a good thing to complete product upgrades without users knowing.

A further benefit is that it will be easier to release a beta or test version. Just tell the user to open your URL in their browser and that's it! There is no need to consider the crazy DRM of iOS, nor the necessary APK of Android.

3. Supports cross-platform and cross-device development: A huge benefit is that my app works on Android and IOS right away, and also on other platforms. As an independent developer, maintaining code base for different platforms is a huge undertaking. Writing high-quality mobile applications for a single mobile platform requires a full-time job, and doing similar things repeatedly for each platform requires a lot of resources. The ability for the app to work on both Android and iOS devices is a huge bonus for me.

Taking it a step further, especially with devices running various forks of Android that come in all sizes and shapes, it’s really important to want your app to look good on phones with a wide variety of screen resolutions. challenges. For demanding Android developers, setting up screen splits based on screen size (zooming from fully minimized to maximized) can take a lot of development time. Since the browser will render it the same way on every device, you don't have to worry about this.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Python vs. JavaScript: A Comparative Analysis for DevelopersPython vs. JavaScript: A Comparative Analysis for DevelopersMay 09, 2025 am 12:22 AM

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Python vs. JavaScript: Choosing the Right Tool for the JobPython vs. JavaScript: Choosing the Right Tool for the JobMay 08, 2025 am 12:10 AM

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript: Understanding the Strengths of EachPython and JavaScript: Understanding the Strengths of EachMay 06, 2025 am 12:15 AM

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScript's Core: Is It Built on C or C  ?JavaScript's Core: Is It Built on C or C ?May 05, 2025 am 12:07 AM

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript Applications: From Front-End to Back-EndJavaScript Applications: From Front-End to Back-EndMay 04, 2025 am 12:12 AM

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Python vs. JavaScript: Which Language Should You Learn?Python vs. JavaScript: Which Language Should You Learn?May 03, 2025 am 12:10 AM

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

JavaScript Frameworks: Powering Modern Web DevelopmentJavaScript Frameworks: Powering Modern Web DevelopmentMay 02, 2025 am 12:04 AM

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

The Relationship Between JavaScript, C  , and BrowsersThe Relationship Between JavaScript, C , and BrowsersMay 01, 2025 am 12:06 AM

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.