如何仅使用 jQuery Mobile 支持触摸事件(无 UI 增强)? [英] How to use jQuery Mobile for its touch event support only (no UI enhancements)?
问题描述
我正在开发一个具有自己的外观和感觉的网络应用.我只想将 jQuery Mobile 用于触摸事件支持.
I’m working on a web app that has its own look and feel. I want to use jQuery Mobile for the touch events support only.
当我链接 jquery.mobile.min.js(不链接 css)时,我的页面布局被破坏了.
When I link jquery.mobile.min.js (without linking the css), then the layout of my page is broken.
如何配置(初始化)jQuery Mobile 以仅使用触摸事件支持?由于我没有任何 JQM 页面相关事件,我是否会在 jQuery 文档就绪挂钩中绑定事件?
How can I configure (initialize) jQuery Mobile to only use touch events support? Would I bind the events in the jQuery document ready hook since I'd not have any JQM page related event?
编辑
在 jsfiddle 中查看此示例:http://jsfiddle.net/redhotsly/JGgrw/.该 html 包含一个 ,但 jQuery Mobile 在其左侧创建了一个
.如果您检查结果标记 (F12),您将看到 jQuery Mobile 还向我的按钮添加了一个 CSS 类.
See this example in jsfiddle: http://jsfiddle.net/redhotsly/JGgrw/. The html contains a <button>
but jQuery Mobile created a <span>
to its left. If you inspect the resulting markup (F12) you will see that jQuery Mobile also added a CSS class to my button.
我需要一个无需修改 JQM 脚本的解决方案.我需要使用 CDN 的官方脚本.
I need a solution where I'll not have modify the JQM script. I need to use the official script off a CDN.
推荐答案
如果你只想绑定到触摸/手势事件,我会改用 jGestures:
If you just want to bind to touch/gesture events I'd use jGestures instead:
http://jgestures.codeplex.com/
我之前在项目中使用过的漂亮的小 jquery 插件,可以绑定大量事件:
Nice little jquery plugin that I've used on projects before with a big range of events to bind to:
可用事件:
orientationchange 设备顺时针或逆时针转动.此事件由设备触发,可能会使用一个内部陀螺仪.
orientationchange The device is turned clockwise or counterclockwise. This event is triggered by the device and might use an internal gyroscope.
捏合 在捏合手势(两个手指彼此远离或靠近)期间触发.
pinch Is triggered during a pinch gesture (two fingers moving away from or towards each other).
rotate 在旋转手势(两个手指顺时针或逆时针旋转)期间触发.
rotate Is triggered during a rotation gesture (two fingers rotating clockwise or counterclockwise).
swipemove 在滑动移动手势(手指在设备周围移动,例如拖动)期间触发
swipemove Is triggered during a swipe move gesture (finger(s) being moved around the device, e.g. dragging)
swipeone 在使用一个接触点(一根手指在设备周围移动)的滑动移动手势后触发
swipeone Is triggered after a swipe move gesture with one touchpoint (one finger was moved around the device)
swipetwo 在使用两个接触点(两个手指在设备周围移动)的滑动移动手势后触发
swipetwo Is triggered after a swipe move gesture with two touchpoints (two fingers were moved around the device)
swipethree 在三个接触点(三个手指在设备周围移动)的滑动移动手势后触发
swipethree Is triggered after a swipe move gesture with three touchpoints (three fingers were moved around the device)
swipefour 在四个接触点(四个手指在设备周围移动)的滑动移动手势后触发
swipefour Is triggered after a swipe move gesture with four touchpoints (four fingers were moved around the device)
swipeup 在严格向上滑动移动手势后触发
swipeup Is triggered after an strict upwards swipe move gesture
swiperightup 在向右和向上滑动移动手势后触发
swiperightup Is triggered after a rightwards and upwards swipe move gesture
swiperight 在严格向右滑动移动手势后触发
swiperight Is triggered after a strict rightwards swipe move gesture
swiperightdown 在向右*向上和向下滑动移动手势后触发
swiperightdown Is triggered after a rig*htwards and downwards swipe move gesture
swipedown 在严格向下滑动移动手势后触发
swipedown Is triggered after a strict downwards swipe move gesture
swipeleftdown 向左和向下滑动移动手势后触发
swipeleftdown Is triggered after a leftwards and downwards swipe move gesture
swipeleft 在严格的向左滑动移动手势后触发
swipeleft Is triggered after a strict leftwards swipe move gesture
swipeleftup 在向左和向上滑动移动手势后触发
swipeleftup Is triggered after a leftwards and upwards swipe move gesture
tapone 在单个(一根手指)点击手势后触发
tapone Is triggered after a single (one finger) tap gesture
taptwo 在双(两个手指)点击手势后触发
taptwo Is triggered after a double (two finger) tap gesture
tapthree 在三次(三指)点击手势后触发
tapthree Is triggered after a tripple (three finger) tap gesture
pinchopen 当一个 pinchopen 手势(两个手指彼此远离)发生并且接触点(手指)被触发时触发移除了设备.
pinchopen Is triggered when a pinchopen gesture (two fingers moving away from each other) occured and the touchpoints (fingers) are removed the device.
捏合 当捏合手势(两个手指相对移动)发生并且接触点(手指)被触发时触发移除了设备.
pinchclose Is triggered when a pinchclose gesture (two fingers moving towards each other) occured and the touchpoints (fingers) are removed the device.
rotatecw 当顺时针旋转手势(两个手指顺时针旋转)发生并且接触点(手指)被触发时触发移除了设备.
rotatecw Is triggered when a clockwise rotation gesture (two fingers rotating clockwise) occured and the touchpoints (fingers) are removed the device.
rotateccw 当发生逆时针旋转手势(两个手指逆时针旋转)并且接触点(手指)移除设备.
rotateccw Is triggered when a counterclockwise rotation gesture (two fingers rotating counterclockwise) occured and the touchpoints (fingers) are removed the device.
这篇关于如何仅使用 jQuery Mobile 支持触摸事件(无 UI 增强)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!