Uncaught ReferenceError: Y is not defined
《before》
var getOdrReiTkts = @Html.Raw(Json.Serialize(Model.OrdersReissueTickets));
var strFinAccountInd = 'N';
if (getOdrReiTkts["length"] != 0) {
strFinAccountInd = @Model.OrdersReissueTickets.Where(x => x.ID_SEQ == @ViewBag.ORTID_SEQ).First().FINANCE_ACCOUNT_IND ;
}
《after》
var getOdrReiTkts = @Html.Raw(Json.Serialize(Model.OrdersReissueTickets));
var strFinAccountInd = 'N';
if (getOdrReiTkts["length"] != 0) {
strFinAccountInd = '@Model.OrdersReissueTickets.Where(x => x.ID_SEQ == @ViewBag.ORTID_SEQ).First().FINANCE_ACCOUNT_IND' ;
}
When you will use model value in javascript if-else statement, you should add '' to wrap the value to us.
Refer:
https://stackoverflow.com/questions/5863094/asp-net-mvc-using-viewdata-in-javascript
No comments:
Post a Comment