1

I have have following line that is working correctly:

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

When I try this I get my JSON displayed.

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>"

I also recieve a bunch of errors such as:

  • 'return' statement outside of function'
  • Expected ';'
  • Syntax error
  • Expected identifier or string

Am I doing something wrong here?

This is the complete function:

 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; 

Thanks in advance!

Obsivus
  • 8,231
  • 13
  • 52
  • 97

1 Answers1

1

This code

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

generates

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

Note that generated anchors do not have string identifiers (' or "), so you get errors. You should change code to

 "</td><td>" + '@(Html.ActionLink("Ändra", "Edit")) | @(Html.ActionLink("x", "Inactive", new { @class = "deleteLink" }))' + "</td>"
archil
  • 39,013
  • 7
  • 65
  • 82