且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从视图内的 javascript 函数更改模型属性?

更新时间:2023-11-29 15:13:04

您无法使用 javascript 执行此操作.模型由控制器实例化并传递给视图.如果要修改某些属性,则需要对控制器操作执行请求并发送新值.这可以使用标准表单或 AJAX 请求来完成.

You can't do this using javascript. The model is instantiated by the controller and passed to the view. If you want to modify some properties you will need to perform a request to a controller action and send the new values. This could be done either using a standard form or AJAX request.