You could do this:
hub.client.printOutPlayerList = function (userName, userID)
{
var link = '<a href="/Profile/Profile/' + userID + '">' + userName + '</a>';
$("#playerlist ul").append('<li>' + link + '</li>');
}
Question
i'm doing a school gaming project and i am trying to create a list of players using SignalR and javascript.
this is my code
hub.client.printOutPlayerList = function (userName, userID)
{
$("#playerlist ul").append("<li>" + '@(Html.ActionLink(userName, "Profile", "Profile", new { id = userID }, null);)' + "</li>");
}
this function is suppose to take in javascript variables userName and userID but the actionlink doesnt seem to recognize userName and userID
what can i do ?
Solution
You could do this:
hub.client.printOutPlayerList = function (userName, userID)
{
var link = '<a href="/Profile/Profile/' + userID + '">' + userName + '</a>';
$("#playerlist ul").append('<li>' + link + '</li>');
}