Comments (4)
Chaplin doesn’t provide an own solution how to sync your models and collections, or imposes any restrictions. That means the standard Backbone way using fetch
, save
, destroy
, sync
and so on should work fine, and this is still the preferable way. So you should be able to reuse the existing code as it is.
The likes example is just a special case. It could be forced into the standard Backbone fetch/sync model but that would be less elegant since Facebook doesn’t provide a RESTful API. We’re going to add a more common example using Backbone’s standard sync methods soon.
from chaplin.
Hi Mathias,
Thanks again for all your responses. I'm truly seeing the elegance of Chaplin and I have been spending many hours studying every part of it. For my notes collection; do you see any problem with fetching the data in my notes_controller? Instead of having the notes initializer call getNotes() and having getNotes() call a service to get data and processNotes() reset the collection; can I have something like below? I'm just not sure where to kick off the collection's fetch. Backbone doesn't have a controller. I want to maintain the same flow as Chaplin. I also want the object (model, collection and view) disposal.
define ['controllers/controller', 'models/notes', 'views/notes_view'], (Controller, Notes, NotesView) ->
'use strict'
class NotesController extends Controller
historyURL: 'notes'
index: (params) ->
#console.debug 'NotesController#index'
notes = new Notes()
notes.fetch()
@collection = notes
@view = new NotesView collection: @collection
If this is not how you would go about it; can you please provide some more clarity as to how to kick off a collection getting its own data from a restful api?
Again, thank you for such a beautiful sample application and for the awesome documentation. My hope is that Chaplin will gain traction in the open source community. It is truly an elegant solution.
Best regards,
Chris
p.s. I got this approach working in part, but, I am very interested to hear your opinion on the approach I'm taking.
from chaplin.
Your code should work fine and this is also a straight-forward way.
Don’t know what NotesView is (probably a CollectionView), but as long as the fetching is asynchronous, listening to model changes in the view should work.
from chaplin.
Thanks Mathias! I now have the restful service returning data. I am moving on to populate the collection view (NotesView).
Best regards,
Chris
Sent from my iPad
On Mar 9, 2012, at 1:57 AM, Mathias Schä[email protected] wrote:
Your code should work fine and this is also a straight-forward way.
Don’t know what NotesView is (probably a CollectionView), but as long as the fetching is asynchronous, listening to model changes in the view should work.
Reply to this email directly or view it on GitHub:
https://github.com/moviepilot/chaplin/issues/8#issuecomment-4413629
from chaplin.
Related Issues (20)
- Access control checks on Controller#beforeAction HOT 3
- Access Control implementation
- View::render - return origin result from wrapped method HOT 5
- noWrap:true doesn't work properly in subviews when top-level element in template is not div HOT 2
- Model not set in Backbone Collection HOT 1
- Backbone 1.2.0 HOT 3
- jQuery#html => setHTML doesn't work in IE11 on win7 HOT 2
- (npm) Update to newer Backbone HOT 4
- itemView with nowrap=true doesn't work when template produces TR HOT 1
- delegate in itemview
- Internet Explorer reload on link with relative URL HOT 1
- Uncaught TypeError: Cannot read property 'undefined' of undefined HOT 8
- CollectionView insert new rows in opposite order to backbone collection models
- Incompatibility upgrading to 1.2.0 from 1.1.1 HOT 3
- Not working Backbone.js link in README.js HOT 1
- New release?
- ListenHash: remove 'model', 'collection' limitation
- Internet Explorer invalid pointer error
- Composer Doc is wrong in regards of `check` method
- Archive the organization
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chaplin.