I've seen posts explaining how to access the model from Javascript:
var theCount = @(Model.Proposal.Count())
The simple code above works. However in the following function I get syntax error (on the semi-colon) when I try to use the above @... code where I want the variable.
$("#ProposalsHeading").click(function () {
if ($("#ProposalsPanel").is(":visible")) {
$("#ProposalsHeading").text("Show Proposals " + @(Model.Proposal.Count()); // SyntaxError error on ";"
}
else {
$("#ProposalsHeading").text("Hide Proposals " + @(Model.Proposal.Count()); // SyntaxError error on ";"
}
$("#ProposalsPanel").slideToggle("slow");
});
I've also tried declaring the variable once and using it in the two locations where I want the "count" to appear, but I again get a syntax error on the semi-colon:
$("#ProposalsHeading").click(functi ...
Go to the complete details ...