Reputation: 13
I am using a select to list all of the site's users. Below the select are fields that contain the selected users information. When i select a different user i would like to refresh the view's model and populate the fields with the new selection's information.
Ultimately, i would like to use a jquery get to return the updated model and refresh the model's state to populate the fields. Is it possible to refresh a model that is already bound to a view with jquery?
Upvotes: 0
Views: 2237
Reputation: 1452
Really no reason to update the model. The model is server side, javascript runs on client side.
You would use an asyncronous call in javascript (maybe jquery.ajax) to a server side method to retrieve some data based on input. (Maybe a good return type would be a JSON object.) Then taking the data in that returned data to populate the existing HTML fields on your users computer. Maybe have a hidden div somewhere that is populated and appears after a users selection is made.
Keep in mind, Once your on the client side, your messing with the html, not the model. The model is server side. JavaScript is Client side.
Upvotes: 1