Jquery ui DragTable中的帮助程序在使用PhoneGap的android应用程序中不起作用
我正在使用phonegap开发的android应用程序中使用jquery ui实现拖放功能。一切正常。我使用了Jquery ui DragTable中的帮助程序在使用PhoneGap的android应用程序中不起作用,jquery-ui,cordova,jquery-mobile,Jquery Ui,Cordova,Jquery Mobile,我正在使用phonegap开发的android应用程序中使用jquery ui实现拖放功能。一切正常。我使用了jquery.ui.touch-punch.js来处理触摸事件。问题是,在android平板电脑中使用触摸拖动时,我没有得到帮助。助手在桌面浏览器中工作正常。jqueryui在jquerymobile中??不可能!他们没有为移动设备优化jquery用户界面。所以不要指望它能顺利运行 您可能需要考虑其他库,如 jquery手机中的jquery用户界面??不可能!他们没有为移动设备优化j
jquery.ui.touch-punch.js
来处理触摸事件。问题是,在android平板电脑中使用触摸拖动时,我没有得到帮助。助手在桌面浏览器中工作正常。jqueryui
在jquerymobile中??不可能!他们没有为移动设备优化jquery用户界面。所以不要指望它能顺利运行
<>您可能需要考虑其他库,如
jquery手机中的jquery用户界面
??不可能!他们没有为移动设备优化jquery用户界面。所以不要指望它能顺利运行
<>您可能需要考虑其他库,如
- 以下是一个工作示例:
我已经在安卓4.1.1和iPad 6.0上进行了测试
要使其正常工作,您还需要添加以下代码:
/iPad|iPhone|Android/.test( navigator.userAgent ) && (function( $ ) {
var proto = $.ui.mouse.prototype,
_mouseInit = proto._mouseInit;
$.extend( proto, {
_mouseInit: function() {
this.element
.bind( "touchstart." + this.widgetName, $.proxy( this, "_touchStart" ) );
_mouseInit.apply( this, arguments );
},
_touchStart: function( event ) {
/* if ( event.originalEvent.targetTouches.length != 1 ) {
return false;
} */
this.element
.bind( "touchmove." + this.widgetName, $.proxy( this, "_touchMove" ) )
.bind( "touchend." + this.widgetName, $.proxy( this, "_touchEnd" ) );
this._modifyEvent( event );
$( document ).trigger($.Event("mouseup")); //reset mouseHandled flag in ui.mouse
this._mouseDown( event );
//return false;
},
_touchMove: function( event ) {
this._modifyEvent( event );
this._mouseMove( event );
},
_touchEnd: function( event ) {
this.element
.unbind( "touchmove." + this.widgetName )
.unbind( "touchend." + this.widgetName );
this._mouseUp( event );
},
_modifyEvent: function( event ) {
event.which = 1;
var target = event.originalEvent.targetTouches[0];
event.pageX = target.clientX;
event.pageY = target.clientY;
}
});
})( jQuery );
我不是这段代码的作者,而是。下面是一个工作示例: 我已经在安卓4.1.1和iPad 6.0上进行了测试 要使其正常工作,您还需要添加以下代码:
/iPad|iPhone|Android/.test( navigator.userAgent ) && (function( $ ) {
var proto = $.ui.mouse.prototype,
_mouseInit = proto._mouseInit;
$.extend( proto, {
_mouseInit: function() {
this.element
.bind( "touchstart." + this.widgetName, $.proxy( this, "_touchStart" ) );
_mouseInit.apply( this, arguments );
},
_touchStart: function( event ) {
/* if ( event.originalEvent.targetTouches.length != 1 ) {
return false;
} */
this.element
.bind( "touchmove." + this.widgetName, $.proxy( this, "_touchMove" ) )
.bind( "touchend." + this.widgetName, $.proxy( this, "_touchEnd" ) );
this._modifyEvent( event );
$( document ).trigger($.Event("mouseup")); //reset mouseHandled flag in ui.mouse
this._mouseDown( event );
//return false;
},
_touchMove: function( event ) {
this._modifyEvent( event );
this._mouseMove( event );
},
_touchEnd: function( event ) {
this.element
.unbind( "touchmove." + this.widgetName )
.unbind( "touchend." + this.widgetName );
this._mouseUp( event );
},
_modifyEvent: function( event ) {
event.which = 1;
var target = event.originalEvent.targetTouches[0];
event.pageX = target.clientX;
event.pageY = target.clientY;
}
});
})( jQuery );
我不是这段代码的作者,而是。但我正在添加jquery.ui.touch-punch.js。它对助手有用吗?对不起,我没有使用jquery ui的经验。但是我正在添加jquery.ui.touch-punch.js。它对助手有用吗?对不起,我没有使用jquery ui的经验。