Where is the correct location for an AJAX call in Backbone.js?
-
14-10-2019 - |
Pergunta
I'm learning Backbone.js for a new app I'm building.
I need to perform an AJAX call to get more properties for my model object (image, title & description of a book).
Where is the correct place for this call? In the Model, View or somewhere else? specifically related to Backbone.js MVC model.
Additional Info
I'm using LocalStorage and not a server. The AJAX call will be to a web service API and constitutes only part of my actual model data.
Solução
If you have properly configured your model you can just call model.fetch()
which will issue a HTTP GET to whatever url
you have configured and refresh the model with the results from the server.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow