Pergunta

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 ?

Nenhuma solução correta

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top