Javascript 调用从动态创建的表中传递文件名的函数

Javascript 调用从动态创建的表中传递文件名的函数,javascript,jquery,html,asp.net-mvc,Javascript,Jquery,Html,Asp.net Mvc,我试图从动态创建的表中传递一个文件名,并获得一些未捕获的引用错误:Q1_58_English_Resume未定义 在htmlanchoreElement.onclick(添加要求:1) 这里的文件名是“Q1_58_英语_简历” 动态表的脚本如下所示 如果(filesData.length>0){ 试试这个,应该管用 var table = ''; table += '<table class="radar-grid-table" id="TableAttach">';

我试图从动态创建的表中传递一个文件名,并获得一些未捕获的引用错误:Q1_58_English_Resume未定义 在htmlanchoreElement.onclick(添加要求:1)

这里的文件名是“Q1_58_英语_简历”

动态表的脚本如下所示

如果(filesData.length>0){

试试这个,应该管用

var table = '';
    table += '<table class="radar-grid-table" id="TableAttach">';
    table += '<thead>';
    table += '<tr>';
    table += '<th>Files</th>'
    //table += '<th>Select</th>';
    table += '<th>Actions</th>';

    table += '</tr>';
    table += '</thead>';
    table += '<tbody>';
    $.each(filesData, function (i, item) {
        table += '<tr>';
        table += '<td>' + item + '</td>';
        //table += '<td title="' + item.AttachmentId + '">' + item.AttachmentId + '</td>';
        //<input value="' + full.QuestionId + '
        table += '<td> <a href="#" id="mylink" onclick="DownloadAttachment('${item}')">Download</a> </td>';

        table += '</tr>';
    });
    table += '</tbody>';
    table += '</table>';

    return table;

}

var表=”;
表+='';
表+='';
表+='';
表+=“文件”
//表+=‘选择’;
表+=‘行动’;
表+='';
表+='';
表+='';
$.each(文件数据、函数(i、项){
表+='';
表+=''+项目+'';
//table+=''+item.AttachmentId+'';

//如果我想传递2个参数,您需要在
“DownloadAttachment('+item+')”
中的
项目周围加引号。
如果我想传递2个参数,任何想法都需要加引号。如何做。如果字符串是
“DownloadAttachment(\'+item+'\',\'+param+'\')”
,否则
“DownloadAttachment(\'+item+'\',+param+)”),+param+)”
function DownloadAttachment(fileName) {
    debugger;
    var url = "/RequirementManagement/OpenFile?ids=" + fileName;
    window.location.href = url;
}
var table = '';
    table += '<table class="radar-grid-table" id="TableAttach">';
    table += '<thead>';
    table += '<tr>';
    table += '<th>Files</th>'
    //table += '<th>Select</th>';
    table += '<th>Actions</th>';

    table += '</tr>';
    table += '</thead>';
    table += '<tbody>';
    $.each(filesData, function (i, item) {
        table += '<tr>';
        table += '<td>' + item + '</td>';
        //table += '<td title="' + item.AttachmentId + '">' + item.AttachmentId + '</td>';
        //<input value="' + full.QuestionId + '
        table += '<td> <a href="#" id="mylink" onclick="DownloadAttachment('${item}')">Download</a> </td>';

        table += '</tr>';
    });
    table += '</tbody>';
    table += '</table>';

    return table;

}