备注按钮显示第二页中第一页的重复数据

时间:2019-07-11 04:29:52

标签: javascript php mysql ajax

用户通过单击列表中的Add Remark按钮来创建评论。 该请求将在管理表列表中显示Remark button(橙色)。

问题解决后。管理员将在“备注”窗口中单击“解决”按钮,表格列表中的“备注”按钮将变为绿色。 现在的问题是为record1(第1页)创建的注释将在record11(第2页)中显示相同。 record3(第一页)将在record13(第二页)中显示相同。

$(".main_table").empty();
$(".main_pagination").empty();
var container = $('.main_pagination');
var rowHeader = '<div class="row header blue">' +
  '<div class="cell _r1">ID</div>' +
  '<div class="cell _r2">Name</div>' +
  '<div class="cell _r3">NRIC No</div>' +
  '<div class="cell _r4">Credit Card No</div>' +
  '<div class="cell _r5">Swipe Amount</div>' +
  '<div class="cell _r6">Action</div>' +
  '<div class="cell _r7">Created By</div>' +
  '<div class="cell _r8">Created Date</div>' +
  '<div class="cell _r9">Status</div>' +
  '</div>';

$(".main_table").html(rowHeader);

var sources = function() {
  var result = [];

  for (var i = 0; i < _data.returnValue.length; i++) {
    result.push(i);
  }

  return result;
}();

var options = {
    dataSource: sources,
    callback: function(response, pagination) {
        //window.console && console.log(response, pagination);
        var dataHtml = "";


        $.each(response, function(index, item) {
              var data = _data.returnValue[item];

              var content = '<div class="row">';
              content += '<div class="cell">' + data['epp_id'] + '</div>';
              content += '<div class="cell">' + data['applicant_name'] + '</div>';
              content += '<div class="cell">' + data['nric'] + '</div>';
              content += '<div class="cell">' + data['cc_number'] + '</div>';
              content += '<div class="cell">' + data['swipe_amount'] + '</div>';
              content += '<div class="cell">';

              var eachRemark = _data["remark"][index];
              var remarkButton = "";

              for (var ii = 0; ii < eachRemark.length; ii++) {

                var solvedGreen = "";

                if (eachRemark[ii]["solved_by_id"] != "0") {
                  remarkButton += '<div class="btn_edit green' + solvedGreen + '" onclick="view_remark(' + "'" + "main" + "'," + "'" + eachRemark[ii]["remark_id"] + "'" + ')">Remark</div>';
                } else {
                  remarkButton += '<div class="btn_edit orange' + solvedGreen + '" onclick="view_remark(' + "'" + "main" + "'," + "'" + eachRemark[ii]["remark_id"] + "'" + ')">Remark</div>';
                }
              }

              if ("<?php echo $_SESSION['login_role']?>" == "master") {
                content += '<div class="btn_edit" onclick="edit_function(' + "'" + "main" + "'," + "'" + data['unique_code'] + "'" + ')">Edit</div>';
                content += '<div class="btn_edit red" onclick="delete_function(' + "'" + "main" + "'," + "'" + data['unique_code'] + "'" + ')">Delete</div>';
                content += '<div class="remark_holder">' + remarkButton + '</div>';
              } else if ("<?php echo $_SESSION['login_role']?>" == "account") {
                content += '<div class="btn_edit" onclick="edit_function(' + "'" + "main" + "'," + "'" + data['unique_code'] + "'" + ')">Edit</div>';
                content += '<div class="remark_holder">' + remarkButton + '</div>';
              } else if ("<?php echo $_SESSION['login_role']?>" == "member") {
                content += '<div class="btn_edit" onclick="edit_function(' + "'" + "main" + "'," + "'" + data['unique_code'] + "'" + ')">View</div>';
                content += '<div class="btn_edit long_btn_edit" onclick="add_remark(' + "'" + "main" + "'," + "'" + data['unique_code'] + "'" + ')">Add Remark</div>';
              }

0 个答案:

没有答案