jquery - How to access MVC PartialView Model in Javascript? -
for accessing model of view javascript can use
var additional = '@html.raw(json.encode(model))';
but how model of partial view main view?
the problem i'm facing load partial view keno ui window widget via jquery ajax call, inside partial view have upload widget , has event ( ie: onupload
event ) , if put onupload
event inside partialview, doesn't recognize it. had put in main view.
in case '@html.raw(json.encode(model))'
return model of main view , not partial one.
any ideas on how resolve problem?
this way have access of model:
var model = function () { return @html.raw(json.encode(model)) }();
the partial view has model:
@model somemodel <script type="text/javascript"> $(document).ready(function() { var model = function () { return @html.raw(json.encode(model)) }(); }); </script>
Comments
Post a Comment