【问题标题】:JQM Click event doesn't work in Android WebviewJQM Click 事件在 Android Webview 中不起作用
【发布时间】:2012-07-08 06:55:31
【问题描述】:

我有一个包含三个元素的锚。每个元素都必须响应点击事件。 我有这个和 Android 网络视图应用程序。

令人惊讶的是,单击事件在 android 浏览器中有效,但是当我尝试使用该 android webview 应用程序时,没有任何反应。请参考下面的代码。

我不知道我错过了什么,所以点击事件在 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");
                            }
                        });
                    }
                }

【问题讨论】:

    标签: android jquery-mobile android-webview


    【解决方案1】:

    知道了。只需要实现 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;         
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多