문제

I'm making a small one-page app with a javascript front-end client connected to a RESTful API.

It's basically a simple CRUD app. I start by fetching handlebars.js templates for the entries and populate them from JSON. This is the easy part.

My problem is when I update the data and want to render the views with the new data. I tend to fetch the JSON data again and rerender all the views with the new changes but I don't think this is a good practice for two reasons : there's another roundtrip to the server that could probably be avoided, and I have to store the state of the UI in variables so once it is rerendered I can set the UI back to the state it was before.

What are the good practices for UI rerendering in javascript views after some data has been updated ?

올바른 솔루션이 없습니다

다른 팁

you do not need to render all your view. you can just change that portion of html using jquery. and update the database using an ajax call. that way u don't need another ajax call to fatch the entire JSON again

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top