2012-07-08 69 views
0

我有一個包含三個元素的錨點。每個元素都必須響應點擊事件。 我有這個和Android Web視圖應用程序。JQM Click事件在Android Webview中不起作用

令人驚訝的是,在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"); 
          } 
         }); 
        } 
       } 

回答

0

明白了。只需實現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;   
     } 
    }