首页 > 解决方案 > 数据表中出现“确认”错误。我应该如何解决它?

问题描述

我在确认中使用数据表列。but('do you want cancel?') 那部分出现错误。编号没有错误,但文字是错误的。我们应该如何改变它?在我的代码中

 'columns': [
                  {
                    "data": null,
                    "bSortable": false,               
                    "mRender": function (o) { if (o.check_flag == 3){ 
                      return '<form action="" method="post" ><input type="hidden" name="idx" value="' +
                      o.po_id + '?' + o.po_point + '">
                     <input type="submit" onclick="if(!confirm('do you want cancel?')){return false;}" 
                      value="cancel"></form>';
                    }else{
                      return '<span>not cancel</span>';
                    }
                    }
                }
                ]

标签: javascriptphphtmldatatables

解决方案


正如@Kevin 在评论中所说,转义单引号。我只是添加\'到您的确认文本的两端。

 'columns': [
                  {
                    "data": null,
                    "bSortable": false,               
                    "mRender": function (o) { if (o.check_flag == 3){ 
                      return '<form action="" method="post" ><input type="hidden" name="idx" value="' +
                      o.po_id + '?' + o.po_point + '">
                     <input type="submit" onclick="if(!confirm(\'do you want cancel?\')){return false;}" 
                      value="cancel"></form>';
                    }else{
                      return '<span>not cancel</span>';
                    }
                    }
                }
                ]

推荐阅读