How to get Data from Model to JavaScript MVC 4?

后端 未结 4 2024
借酒劲吻你
借酒劲吻你 2021-02-13 23:10

that\'s my function:

 

        
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-13 23:33

    If you prefer a class try jsmodel. After converting the mvc view model to javascript it adds the benefit of retrieving DOM updates.

    var jsmodel = new JSModel(@Html.Raw(Json.Encode(Model)));
    

    Then anytime you want to get the latest state of the DOM do this to update your variable:

    var model = jsmodel.refresh();
    

    Website: http://chadkuehn.com/jquery-viewmodel-object-with-current-values/

    There is also a nuget: https://www.nuget.org/packages/jsmodel/

提交回复
热议问题