Evaluate Razor variable in javascript
I need to evaluate a razor variable inside a javascript function. Given
the following code:
@{var unseenNotificationsExist = false;}
@foreach(var notification in viewModel)
{
if (notification.WasSeen == false)
{
unseenNotificationsExist = true;
break;
}
}
I need to evaluate the unseenNotificationsExist variable in javascript
like this:
if(@unseenNotificationsExist == true)
$('#unseenNotifCount').addClass('notifNotSeen');
However, when i debug the javascript code, i get this:
if(True == true)
and also I get an Uncaught ReferenceError True is not defined
No comments:
Post a Comment