-3

我正在尝试创建一个动态 html td,如下所示:

var id = "testId";
var issueId = "testIssueId";

var sourceRow = ($(this).find("OBJECTID").text() === "") ? '<td></td>' : "<td><img src='contactImages/attachmentImage.png' onclick='issueAttachmentAttachmentLookUp('"+id+"','"+issueId+"')'> </img></td>" ;

当我点击上面 td(在 Firefox 中)时,我收到以下错误:

语法错误:预期的表达式,得到 '}'

功能是:

function issueAttachmentAttachmentLookUp(strIssueID, issueID1)
{
    var aryArgument = new Array();

    aryArgument[0] = m_stateData;
    aryArgument[1] = g_ContactSoapWebServiceURL;
    aryArgument[2] = g_PQContactTree;
    aryArgument[3] = strIssueID;
    aryArgument[4] = m_PQClientConfig;
    aryArgument[5] = g_BAList;
    aryArgument[6] = g_references;
    aryArgument[7] = ResponseNode;
    aryArgument[8] = issueCurrentBA;
    aryArgument[9] = issueID1;

    ModalHelper.showModalDialog(
        'PQCaseAttachment.htm',
        'Issue Attachments',
        890,
        700,
        aryArgument,
        function(refreshWindow)
        {
            if(refreshWindow){
                refresh();
            }
        }
    );
}

我怀疑 onclick 事件语法有问题,但无法识别问题。

有人有任何线索吗?

4

2 回答 2

1

您有语法错误。你的第二行应该是:

var issueId = "testIssueId";
于 2018-11-28T14:03:57.647 回答
0

你有太多的单引号。您的onclick遗嘱如下所示:

onclick='issueAttachmentAttachmentLookUp('id','issueId')'
        ^                                ^  ^ ^       ^ ^

看看有没有额外的单引号?将这些替换\"为 onclick 内部:

onclick=\"issueAttachmentAttachmentLookUp('"+id+"','"+issueId+"')\"
于 2018-11-28T14:05:06.667 回答