1

我有以下工作正常:

 html: "<td>" + goalcard.Name + "</td><td>" + goalcard.Customer + "</td><td>" + goalcard.PlannedDate + "</td><td>" + goalcard.CompletedDate + "</td>"

当我尝试这个时,我会显示我的 JSON。

html: "<td>" + goalcard.Name + "</td><td>" + goalcard.Customer + "</td><td>" + goalcard.PlannedDate + "</td><td>" + goalcard.CompletedDate + "</td><td>" +  @Html.ActionLink("Ändra", "Edit") | @Html.ActionLink("x", "Inactive", new { @class = "deleteLink" }) + "</td>"

我还收到一堆错误,例如:

  • 函数外的'return'语句'
  • 预期的 ';'
  • 语法错误
  • 预期的标识符或字符串

我在这里做错了吗?

这是完整的功能:

 result.forEach(function (goalcard) {
                                $("#GoalcardSearchResult tbody").append(
                                    $('<tr/>', {
                                        click: function() {
                                            id = goalcard.Id;
                                            var url = '@Url.Action("AnswerForm", "AnswerNKI", new { id = "__id__"})';
                                            window.location.href = url.replace('__id__', id);


                                        },
                                        // steg Create a row for each result 
                                        html: "<td>" + goalcard.Name + "</td><td>" + goalcard.Customer + "</td><td>" + goalcard.PlannedDate + "</td><td>" + goalcard.CompletedDate + "</td><td>" +  @(Html.ActionLink("Ändra", "Edit")) | @(Html.ActionLink("x", "Inactive", new { @class = "deleteLink" })) + "</td>"
                                    }));
                            });
                            $('#GoalcardSearchResult tbody').trigger("update");                                
                            $("#GoalcardSearchResult").tablesorter();
                        });

                        return false; 

提前致谢!

4

1 回答 1

1

这段代码

 "</td><td>" + @(Html.ActionLink("Ändra", "Edit")) | @(Html.ActionLink("x", "Inactive", new { @class = "deleteLink" })) + "</td>"

生成

"</td><td>" + <a href="/Examination/CertificationAnnouncements/Edit">&#196;ndra</a> | <a href="/Examination/CertificationAnnouncements/Inactive?class=deleteLink">x</a> + "</td>"

请注意,生成的锚点没有字符串标识符(' 或 "),因此会出现错误。您应该将代码更改为

 "</td><td>" + '@(Html.ActionLink("Ändra", "Edit")) | @(Html.ActionLink("x", "Inactive", new { @class = "deleteLink" }))' + "</td>"
于 2012-05-08T09:27:06.540 回答