【问题标题】:jQuery mobile panel doesn't close fully only on Android browserjQuery 移动面板不会仅在 Android 浏览器上完全关闭
【发布时间】:2015-06-03 09:14:32
【问题描述】:

JSFiddle:http://jsfiddle.net/nbh1rn33/

我对 jQm 面板有一个奇怪的问题。

打开的面板没有完全关闭。见下图:

奇怪的是,这只发生在 Android 浏览器上,而不是 PC(Chrome、IE)上。

这是 jQm 的错误还是我做错了什么?

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.css" rel="stylesheet"/>
    <script src="https://code.jquery.com/jquery-2.1.4.js"></script>
    <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>
</head>
<body>
    <div data-role="page">
        <div data-role="header" data-position="fixed" >
            <h1>Test Page</h1>
            <div data-type="horizontal" data-role="controlgroup">  
                <a href="#search_condition_panel" id="search_condition_btn" class="ui-btn ui-btn-inline ui-mini ui-corner-all ui-btn-icon-right ui-icon-grid">Show Options</a>
            </div>
        </div>
        <div role="main" class="ui-content">
        </div>
        <div data-position-fixed="true" data-role="panel" data-display="overlay" id="search_condition_panel" data-position="right">
            <div class="ui-field-contain">
                <label for="search-condition-select-brand">Brand</label>
                <select id="search-condition-select-brand" name="search-condition-select-brand" data-mini="true">
                </select>
            </div>
        </div>
        <div id="datepicker"></div>
    </div>
</body>
</html>

【问题讨论】:

  • 您的代码在我的 nexus Android 5.1.1 上运行良好,您尝试的是哪个浏览器和操作系统版本?
  • Galqxy S4 Android 4.4.2 默认浏览器。
  • 我尝试在我的 PC 上将网站模拟为 Chrome 中的三星 S4,但未能成功重现该问题。我还在 Note 4 上尝试了股票浏览器,但没有成功。您手机上的其他浏览器是否也会出现这种情况?
  • @John Carpenter 这只发生在股票浏览器上。我刚刚在 Android chrome 上尝试过,该网站运行良好。如果有帮助的话,手机型号是 SHV-E300S。
  • 我可怕的解决方法是在面板关闭时重新加载页面:$(document).on('pageinit', function() { $('[data-role="panel"]').on("panelclose", function( event, ui ) { location.reload(); }); });

标签: javascript android jquery html jquery-mobile


【解决方案1】:

看起来像 jQuery UI 错误,对于 1.4.2,它不能是 reproduced,对于 1.4.5,它不能是 reproduced。在我的 Galaxy S4 上测试

您的情况的主要区别在于 .ui-panel-closed 类的 сss 属性:

/* 1.4.5 */
.ui-panel-closed {
  width: 0;
  max-height: 100%;
  overflow: hidden;
  visibility: hidden;
  left: 0;
  clip: rect(1px,1px,1px,1px);
}
/* 1.4.2 */
.ui-panel-closed {
  width: 0;
  max-height: 100%;
  overflow: hidden;
  visibility: hidden;
}

如果你重置 left .ui-panel-closed 的 css 属性,所有 fine 都可以工作:

.ui-panel-closed {
  left: auto !important; // left auto fix problem
}

【讨论】:

  • 哇是的,解决了这个问题。我想知道您是如何通过电话调查此问题的
  • 没什么特别的,只检查css属性。在 Android 上,您可以将 remote debugger 用于 Chrome 或将 Weinre 用于 Android 默认浏览器
猜你喜欢
  • 1970-01-01
  • 2020-11-06
  • 1970-01-01
  • 2012-04-11
  • 2012-03-11
  • 2018-04-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多