Javascript 可拖动的非模式弹出Jquery Mobile
我希望在Jquery mobile中有一个弹出窗口,它不会阻止用户与页面交互,并且data dismissible=“false”也就是说,当与页面的另一部分交互时,弹出窗口不会消失并保持可见 我试过这个Javascript 可拖动的非模式弹出Jquery Mobile,javascript,jquery,jquery-mobile,cordova,Javascript,Jquery,Jquery Mobile,Cordova,我希望在Jquery mobile中有一个弹出窗口,它不会阻止用户与页面交互,并且data dismissible=“false”也就是说,当与页面的另一部分交互时,弹出窗口不会消失并保持可见 我试过这个 $('#popupNew').popup({ dismissible: false }); $('#popupNew').popup('open'); 但这会创建一个模式弹出窗口,阻止用户与页面的其余部分交互。Intro 我希望这就是你需要的一切 如果单击弹出窗口外部的曲面,则无法关闭
$('#popupNew').popup({ dismissible: false });
$('#popupNew').popup('open');
但这会创建一个模式弹出窗口,阻止用户与页面的其余部分交互。Intro
我希望这就是你需要的一切
- 如果单击弹出窗口外部的曲面,则无法关闭弹出窗口
- 现在可以访问弹出窗口下面的元素
- 弹出窗口可拖动(在Firefox、Chrome、Android Chrome上测试)
#popup基本屏幕
工作示例
工作示例:
使用的代码
HTML:
CSS:
查看jQueryUIlib,他们有一个很好的“对话框”小部件,可以轻松构建弹出窗口:)!我需要的是一个非模态弹出窗口,谢谢你的css!如果我在这个模式中放置任何按钮,它们就不能被按下。有没有关于如何解决这个问题的建议?编辑:NVM。通过在弹出窗口中应用句柄“[data role='header']”使其正常工作。拖拽和按钮起作用(呜呜:)
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<!--<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>-->
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<div data-role="page" id="index">
<div data-theme="b" data-role="header">
<h1>Index page</h1>
</div>
<div data-role="content">
<a href="#popupBasic" data-rel="popup" data-role="button" data-inline="true" data-transition="pop" >Basic Popup</a>
<a data-role="button" id="test">click me</a>
<div data-role="popup" id="popupBasic" data-dismissible="false">
<a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a>
<p>This is a completely basic popup, no options set.</p>
</div>
</div>
</div>
</body>
</html>
$(document).on('pagebeforeshow', '#index', function(){
$('#popupBasic').draggable({
cursor: 'move'
});
$(document).on('click', '#test', function(){
alert('Successful click!');
});
});
// This is a fix for mobile devices,, rest of the code is not mine
/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 ) {
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 );
#popupBasic-screen {
display: none;
}