未捕获的ReferenceError:未定义错误

时间:2017-04-21 02:58:04

标签: javascript jquery jqgrid

我在下面有这个jqgrid代码,我在里面有一张图片,同时我正在使用它的功能。但是点击我的jqgrid里面的按钮就会显示Uncaught ReferenceError: clickmeapproved is not defined。我的代码或我使用它们的方式有什么问题吗?与拒登的按钮相同的错误。

 afterInsertRow: function (rowid) {
              var obj = jQuery("#FiTATimeCorrectionV2List").getRowData(rowid);
              var FADTLSID = obj.FitaAssignDtlID;
              if (FADTLSID !== undefined) {
                  if (FADTLSID !== "") {
                      var btnApprove = "<input type = 'image' img alt='' src='../../Content/Images/newimages/check.png' style='height:20px;width:20px;'  style ='width: 90px' id='btnApproved" + rowid + "' onclick='clickmeapproved(" + rowid + " )' />"
                      var btnDisApprove = "<input type = 'image' img  alt='' src='../../Content/Images/newimages/delete.png' style='height:20px;width:20px;' style ='width: 90px' id='btnDisApproved" + rowid + "' onclick='clickmedisapproved(" + rowid + " )' />"
                      jQuery("#FiTATimeCorrectionV2List").setRowData(rowid, { FitaCorForApproval: btnApprove });
                      jQuery("#FiTATimeCorrectionV2List").setRowData(rowid, { FitaCorForDisApproval: btnDisApprove });
                      var temp = obj.FitaStatus;
                      if (temp == "Approved") {
                          $("#btnApproved" + rowid).hide();
                          $("#btnDisApproved" + rowid).hide();
                      }
                      else if (temp == "Disapproved") {
                          $("#btnApproved" + rowid).hide();
                          $("#btnDisApproved" + rowid).hide();
                      } else {
                          $("#btnApproved" + rowid).show();
                          $("#btnDisApproved" + rowid).show();
                      }
                  }
              }
          },
function clickmeapproved(rowid) {
var ans = confirm("Are you sure you want to approve the request of "+ globalFitaCorName +"?");
if (ans) {
    $.ajax({
        type: "POST",
        url: '../Request/SaveFitaApproval?FAID=' + rowid,
        dataType: 'json',
        success: function (response) {
            alert("Successfully approve!");
            $("#FiTATimeCorrectionV2List").trigger("reloadGrid");
            FiTATimeCorrectionV2(0);
            globalFitaCorName = "";
            $("#loader").hide();
        },
        error: function (reponse) {
            $("#FiTATimeCorrectionV2List").trigger("reloadGrid");
            FiTATimeCorrectionV2(0);
            globalFitaCorName = "";
            $("#loader").hide();
        }
    });
  }
}

2 个答案:

答案 0 :(得分:0)

您的&#34; clickmeroved&#34;功能没有全局范围。通过键入&#34; window.clickmeapproved&#34;进行检查在网络检查员。

答案 1 :(得分:0)

以下是我用来解决问题的代码。

var btnApprove = "<input type = 'image' img alt='' src='../../Content/Images/newimages/check.png' style='height:20px;width:20px;'  style ='width: 90px' id='btnApproved" + rowid + "' />" 
var btnDisApprove = "<input type = 'image' img  alt='' src='../../Content/Images/newimages/delete.png' style='height:20px;width:20px;' style ='width: 90px' id='btnDisApproved" + rowid + "' />"

我从中排除了按钮点击。

$("#btnApproved" + rowid + "").click(function(){
   clickmeapproved(rowid);
});
$("#btnDisApproved" + rowid + "").click(function(){
   clickmedisapproved(rowid);
});