create object adjustementtype inside script tag in mvc 5 partial view.
<script type="text/javascript"> var adjustementtype = { -1:'rate decrease', 1: 'rate increase' }; </script>
but getting following error "expected identifier, string or number" . error thrown on area -1 & 1 field.
you cannot use strings spaces because defining variables , should turn type around this:
var adjustementtype = { ratedecrease: -1, rateincrease: 1 }; alert(adjustementtype.ratedecrease); //-1
this because defining enums.
edit: can use strings spaces dealing them arrays. think doesn't make sense.
var enumtype = { "-1": "rate decrease", "1" : "rate increase"}; alert(enumtype["1"]); //rate increase alert(enumtype["-1"]); //rate decrease
Comments
Post a Comment