juliocesar / backbone-book Goto Github PK
View Code? Open in Web Editor NEWA booklet on Backbone.js and JS apps patterns and best practices
Home Page: http://pragmatic-backbone.com
A booklet on Backbone.js and JS apps patterns and best practices
Home Page: http://pragmatic-backbone.com
Hi,
Thanks for the book, it's a great read (and I like the fact it's opinionated).
Throughout the book you advocate only writing to the DOM and "never" reading from it. My question is, if I never read from the DOM, how am I supposed to read data entered by the user in form elements (so I can subsequently update relevant model(s)).
Am I missing something?
Thanks
Rob
Would be great to link from each chapter to the next.
Which is used to navigate up/down pages.
This is a really stupid feature anyway. Either just use javascript, or have something you click. No one needs to toggle back and forth and read documentation how to.
Only Coffeescript renders, javascript view has no visible code.
Hello and thank You for the book.
I would like to refer to "Rendering should be a destructive operation as far as what’s in the container element goes."
Say I have a nested tree view with some branches expanded. I guess the model for such a tree would be Model
with ModelCollection
as children
property. And also I will have ModelView
and ModelCollectionView
for display. Now say I change a name/label of one of the expanded branches.
If I destroy this ModelView
and re-render it - I should be able to reconstruct the whole sub-tree somehow. I need to know which branches were opened and which were closed, etc.
It becomes more complex if the sub-trees are dynamically loaded as the user expands the branches.
Just a thought...
I was implementing a presenter object in a project follow the example that can be found on the view page: http://pragmatic-backbone.com/views.
The BookPresenter extends the ModelPresenter using Underscore's extend method
var BookPresenter = _.extend(ModelPresenter.prototype, {
...
});
This ends up adding the new methods (isPaid and isReturned) to ModelPresenter and assigning an object to BookPresenter. You can't then create a new instance of BookPresenter using the next example without getting an error as it isn't a function.
var presenter = new BookPresenter({model: this.model});
I'm not using coffeescript so haven't investigated that any further. I was able to get this working in my project doing the following.
var BookPresenter = function(options){
ModelPresenter.apply(this, arguments);
};
BookPresenter.prototype = _.extend(BookPresenter.prototype, ModelPresenter.prototype, {
isPaid: function(){
...
},
isReturned: function(){
...
}
});
I haven't put this through as a Pull request because I'm not entirely sure if that's the best solution available but I'm happy to if it is.
Hi!
I am reading the page on Routing and Controllers and I cannot understand the following paragraph:
"With that, when navigating away from this screen and back to it, it'll seem as if my catalogue of books just rendered instantly. But for instance, if this screen loads only the 20 newest books introduced to my catalogue, and elsewhere in the screen the app displays a link to an older book of mine because someone left a comment in it."
From the 2nd sentence I cannot understand the meaning, or is it incomplete?
Thanks
Hello and thank you for the book!
I am trying to use your ideas and the part about getting rid of tagName
and className
and placing them inside the template sounded very nice.
But it works only when the View
is added to the DOM
by something/someone else. When the View
needs to re-render itself (on Model
's change) - it removes itself from the DOM
and does not know how and where to insert itself again.
I am trying to render a list of items, where the user can click on the item and select/deselect it. I have the following template (Handlebars):
<li class="{{#if isActive}}active{{/if}}">
<i class='fa-li fa'></i><span>{{name}}</span>
</li>
The isActive
is a property on my ItemView
class and I merge several properties from my ItemView
with it's model creating a ViewModel
which I pass to the template.
My ListView
is rendering each item by instantiating ItemView
and inserting it into a DOM - all is OK.
The problem is that after a click my view is removed from the DOM. Also the item's position in the list is lost.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.