简体   繁体   English

JQM Click事件在Android Webview中不起作用

[英]JQM Click event doesn't work in Android Webview

I have an anchor which has three elements. 我有一个包含三个要素的锚点。 Each element will has to respond for a click event. 每个元素都必须响应单击事件。 I have this as and Android web view app. 我有这个和Android网络视图应用程序。

Surprisingly click event works in android browser, but when I try that android webview app, nothing happens. 令人惊讶的是,单击事件在android浏览器中有效,但是当我尝试该android webview应用程序时,没有任何反应。 Please refer the code below. 请参考下面的代码。

I don't know what I am missing so the click events doesn't work in android webview app. 我不知道自己缺少什么,因此点击事件在android webview应用程序中不起作用。

$("#cont2 li a").live('click', function (e) {
                //e.preventDefault();
                this.blur();

                var name = $(this).attr("name");
                var staffid = $(this).attr("staffid");
                var recordid = $(this).attr("recordid");
                var primary = $(this).attr("primary");

                if (name == "deletestaff") {
                    // delete sales staff
                    var dretVal = confirm("Delete contact staff " + $(this).attr("staffname") + "?");
                    if (dretVal == false) {
                        return false;
                    } else {

                        var txtprimaryrecordid = $("#txtprimaryrecordid").val();
                        var txtprimarystaffid = $("#txtprimarystaffid").val();

                        if (txtprimaryrecordid == 'undefined') {
                            txtprimaryrecordid = "";
                        }

                        if (txtprimarystaffid == 'undefined') {
                            txtprimarystaffid = "";
                        }

                        if (txtprimaryrecordid == recordid) {
                            $("#txtprimaryrecordid").val("");
                        }
                        if (txtprimarystaffid == staffid) {
                            $("#txtprimarystaffid").val("");
                        }

                        $(this).parents('li').remove();

                        // show deleted item
                        $('#staffs input[type=checkbox]').each(function () {
                            var delstaffid = $(this).attr("staffid");

                            if (staffid == delstaffid) {
                                $(this).attr("checked", false).checkboxradio("refresh");
                            }
                        });
                    }
                }

Got it. 得到它了。 Just had to implement WebChromeClient... 只需实现WebChromeClient ...

private class WebChromeClient extends WebChromeClient{
        @Override
        public boolean onJsAlert(WebView view, String url, String message,JsResult result) 
        {
            Log.e("alert triggered", message);
            return false;         
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM