小云菜
小云菜
  • 发布:2015-04-15 16:30
  • 更新:2015-04-15 16:57
  • 阅读:2568

弹出菜单获取返回值关闭弹出,页面自动重新刷新了一次,怎么解决?

分类:MUI

如题,测试环境是android,机子oppo find5
代码如下,页面样式参考的是git-mui-examples-logind-git注册页面git-mui-examples-hellomui弹出层代码, 代码如下:

<!DOCTYPE html>  
<html>  

    <head>  
        <meta charset="utf-8">  
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />  
        <title></title>  
        <link href="../css/mui.min.css" rel="stylesheet" />  
        <style type="text/css">  
            html,  
            body {  
                background-color: #efeff4;  
            }  
            .mui-content {  
                padding: 5px;  
            }  
            .mui-title {  
                font-size: larger;  
            }  
            .area {  
                margin: 30px auto 0px auto;  
            }  
            .mui-input-group {  
                margin-top: 10px;  
                border-radius: 5px;  
                -webkit-border-radius: 5px;  
                /*border:1px solid rgb(200, 199, 204);*/  
            }  
            /*.mui-input-row:after {  
                left: 0px !important;  
            }*/  

            .mui-input-group:first-child {  
                margin-top: 50px;  
            }  
            .mui-input-group label {  
                width: 28%;  
            }  
            .mui-input-row label~input:not([id="authcode"]),  
            .mui-input-row label~select,  
            .mui-input-row label~textarea {  
                width: 72%;  
            }  
            .mui-checkbox input[type=checkbox],  
            .mui-radio input[type=radio] {  
                top: 6px;  
            }  
            .mui-content-padded {  
                margin-top: 25px;  
            }  
            .mui-btn-block {  
                padding: 12px 0px;  
            }  
            #autocode {  
                width: 40%;  
                float: left;  
            }  
            #getcode {  
                float: right;  
                width: auto;  
                border-width: 0;  
                margin-top: 2px;  
            }  
            #popover {  
                position: fixed;  
                top: 20%;  
                right: 6px;  
            }  
            #popover .mui-popover-arrow {  
                left: auto;  
                right: 70%;  
            }  
            span.mui-icon {  
                font-size: 14px;  
                color: #007aff;  
                margin-left: -15px;  
                padding-right: 10px;  
            }  
            .mui-popover {  
                height: auto;  
                min-height: 250px;  
            }  
        </style>  
    </head>  

    <body>  
        <header class="mui-bar mui-bar-nav">  
            <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>  
            <h1 class="mui-title">注册</h1>  
        </header>  
        <div class="mui-content">  
            <form class="mui-input-group">  
                <div class="mui-input-row">  
                    <label>您的职业</label>  
                    <input id='occupation' type="text" class="mui-input-clear mui-input" placeholder="请输入职业">  
                </div>  
                <div class="mui-input-row">  
                    <label>手机号</label>  
                    <input id='account' type="text" class="mui-input-clear mui-input" placeholder="请输入手机号">  
                </div>  
                <div class="mui-input-row">  
                    <label>验证码</label>  
                    <input id='autocode' type="text" class="mui-input-clear mui-input" placeholder="请输入验证码">  
                    <button class="mui-btn mui-btn-positive mui-btn-outlined" id="getcode" onclick="mui.toast('该功能暂未开放');return false;">获取验证码</button>  

                </div>  
                <div class="mui-input-row">  
                    <label>密码</label>  
                    <input id='password' type="password" class="mui-input-clear mui-input" placeholder="密码">  
                </div>  
                <div class="mui-input-row">  
                    <label>确认</label>  
                    <input id='password_confirm' type="password" class="mui-input-clear mui-input" placeholder="确认密码">  
                </div>  
            </form>  
            <div class="mui-content-padded">  
                <button id='reg' class="mui-btn mui-btn-block mui-btn-primary">注册</button>  
            </div>  
        </div>  
        <div id="popover" class="mui-popover">  
            <div class="mui-popover-arrow"></div>  
            <div class="mui-scroll-wrapper">  
                <div class="mui-scroll">  
                    <ul class="mui-table-view">  
                        <li class="mui-table-view-cell"><a href="#" data-sel="1">Item1</a>  
                        </li>  
                        <li class="mui-table-view-cell"><a href="#" data-sel="2">Item2</a>  
                        </li>  
                        <li class="mui-table-view-cell"><a href="#" data-sel="3">Item3</a>  
                        </li>  
                        <li class="mui-table-view-cell"><a href="#" data-sel="4">Item4</a>  
                        </li>  
                        <li class="mui-table-view-cell"><a href="#" data-sel="5">Item5</a>  
                        </li>  

                    </ul>  
                </div>  
            </div>  

        </div>  
        <script src="../js/mui.min.js"></script>  
        <script src="../js/login.js" type="text/javascript" charset="utf-8"></script>  
        <script type="text/javascript" charset="utf-8">  
            (function($, doc, app) {  
                $.init();  
                $.plusReady(function() {  
                    var settings = app.getSettings();  
                    var occupation = doc.querySelector('#occupation');  
                    var occupationval=undefined;  
                    var regButton = doc.querySelector('#reg');  
                    var accountBox = doc.querySelector('#account');  
                    var passwordBox = doc.querySelector('#password');  
                    var passwordConfirmBox = doc.querySelector('#password_confirm');  
                    occupation.addEventListener('tap', function(event) {  
                        $("#popover").popover('toggle');  
                    });  
                    $(".mui-table-view li a").each(function() {  
                        this.addEventListener('tap', function() {  
                            occupationval=this.getAttribute('data-sel');  
                            occupation.value=this.innerText;  
//                          console.log(occupation.value);  
                            $("#popover").popover('toggle');  

                        });  
                    });  
                    regButton.addEventListener('tap', function(event) {  
                        var regInfo = {  
                            account: accountBox.value,  
                            password: passwordBox.value  
                        };  
                        var passwordConfirm = passwordConfirmBox.value;  
                        if (passwordConfirm != regInfo.password) {  
                            plus.nativeUI.toast('密码两次输入不一致');  
                            return;  
                        }  
                        app.reg(regInfo, function(err) {  
                            if (err) {  
                                plus.nativeUI.toast(err);  
                                return;  
                            }  
                            $.openWindow({  
                                url: 'login.html',  
                                id: 'login'  
                            });  
                        });  
                    });  
                });  
            }(mui, document, loginx));  
        </script>  
    </body>  

</html>
2015-04-15 16:30 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

我这里测试没发现刷新
你的android版本是多少?
你可以把href="#"替换成href="javascript:;"再试试,

因为我这里没有你的login.js。不清楚你的login.js是否有影响

小云菜

小云菜 (作者) - 相关代码及分享在http://www.cnblogs.com/phillyx

哎呀,我去,不好意思啊,二逼了,没注意到,就是这个的问题。
麻烦了 ,sorry,这个东西该我自己排查的。。。
3q

该问题目前已经被锁定, 无法添加新回复