This App let you search Twitter for a custom query.
Just enter some text in the form below then press "enter"!
Then try to press "Esc" while entering text or double clicking the input field.
This is a really simple improvement of the Example 008 about Collections.
Here we handle User Inputs to set what to search for.
TwitterSearch App lyes in a global namespace "App".
Internally are stored all components al follow:
Try this code in your console!
App.tweets.search('@thepeg');
When you perform a search the App creates a list of models, one per tweet.
Then there is a View that creates one sub-view per tweet binding it's model.
This works because we want to render each result by compiling a template with model's data.
But TweetView can listen to binded model's "change" event to re-render itself!
Try this code in your console!
App.tweets.models[0].set('text','new text for the tweer');
Objects never calls direct methods in this app! Even when methods are internal!
All interactions belongs to events!
What happen when clicking "go"?
this.collection.trigger( 'performSearch', this.$input.val() );
this.trigger( 'searchStart', q );
It may seems a little verbose logic for a small application like TwitterSearch but coding (and thinking) this way ensures to maintain responsibilities of different objects separate form every else objects!