

Backbone.js v0.9.10 Released - philfreo
http://backbonejs.org/#upgrading

======
marcusestes
"Most importantly, Backbone events have two new methods: listenTo and
stopListening... When you destroy Views with view.remove(), this will now be
done automatically"

Well that seems incredibly useful.

~~~
mcrider
Wait, so in previous versions, when you destroy a view, event listeners
weren't destroyed? I haven't noticed any issues in my Backbone app but this
seems like it could spiral into a memory issue.

~~~
playhard
Yes. The event listeners were not removed with currentView.remove(). Had to
use currentView.unbind() to remove the event listeners.

------
crescentfresh
> Backbone's only hard dependency is either Underscore.js ( >= 1.4.3) or Lo-
> Dash

First I'm hearing of Lo-Dash. How long has this been in the Backbone.org docs?

Appears there was a fair bit of tension in it's dev history. Eg:
[https://github.com/documentcloud/underscore/commit/4e4bc194c...](https://github.com/documentcloud/underscore/commit/4e4bc194c0a0e06aa8f7633695ad10030d871a2b)

~~~
ezequiel-garzon
Backbone begot Spine, Underscore begot Lo-Dash... What about CoffeeScript?
TeaMacro? Jeremy must be having a blast.

~~~
joshuacc
CoffeeScript begat Coco. And Coco begat LiveScript.

------
hueyp
From the changelog:

> Model validation is now only enforced by default in Model#save and no longer
> enforced by default upon construction or in Model#set, unless the
> {validate:true} option is passed.

From the documentation on Model#set:

> If the model has a validate method, it will be validated before the
> attributes are set, no changes will occur if the validation fails, and set
> will return false. Otherwise, set returns a reference to the model. You may
> also pass an error callback in the options, which will be invoked alongside
> the "error" event, should validation fail.

Is the documentation out of sync, or do I not understand the changelog
correctly?

~~~
jashkenas
Thanks for catching that. I've removed the outdated paragraph and republished
the docs. If you notice anything else amiss, please let me know.

~~~
hueyp
Thanks, I was honestly confused, not trying to nit pick.

\---

Anyone know the best way to make it so set defaults to {validate:true}?
Override Backbone.Model.set, extend options and call original?

~~~
philfreo
Sure (though I recommend just updating your code instead...)

Only reason it's tricky is because there are two different forms of attributes
that can be passed to set. Something like this should work:

    
    
      var oldSet = Backbone.Model.prototype.set;
      Backbone.Model.prototype.set = function(key, val, options) {
          if (key == null) return this;
          if (typeof key === 'object') {
            options = val;
          }
          options || (options = {});
          options.validate = true;
          oldSet.call(this, key, val, options);
      };

------
jonascopenhagen
Another framework worth checking out if you're into JavaScript MVC is
AngularJS (<http://angularjs.org>).

~~~
graue
I'd be interested to hear from anyone who's used both Backbone and Angular.

I've been writing my first single-page app (yeah, yeah, behind the times)
using Backbone, and at first it was really exciting and intuitive, but I'm
starting to realize Backbone is a pretty, er, bare-bones lib. Everyone seemed
to suggest Handlebars as a template lib, so I added that to my project, and
RequireJS to manage those two libs and their dependencies, and the RequireJS
text plugin to load templates from other files in the project, and now it all
just seems like a mess. The promise of a framework with everything you need,
right out of the box, is tempting.

Edit: Most of the alternatives (e.g. Ember, Angular, Knockout, Meteor, etc.)
are already in my bookmarks. I'm looking for reports from people who actually
used the things, not links.

~~~
tlarkworthy
I write and use _alot_ of software. Normally number crunching on servers.
However, I recently started seriously learning javascript. I had avoided
HTML/javascript for years as they were horrible systems to develop in compared
to every other type of software system in existence. However, with HTML 5 +
cloud computing platforms I thought these systems are probably mature enough
to start using. Anyway, so I learnt javascript and have now built 2 cloud
apps. The first was to learn the basic ropes of GAE with JS. The second one is
much nearer to to what I would consider complicated (but still one hop from my
final target app). I realised plain JS wasn't scaling (regarding software
entropy) so I looked at frameworks that could tidy things up. Note I have
plenty of experience choosing software APIs to connect different systems
together, but next to no experience of JS specifically. Anyway I tried
backbone and I was like "is that it? the JS community is blown away by a
fricking event model?". It seems trivial to me.

Then I tried AngularJS and I was blown away. "Yes!" I exclaimed "JS/HTML5 has
truly come of age". It is a beautiful thing that saves shit tons of time. And
as I have got deeper into it, I hardly write JS anymore, YOU CAN DO 95% OF
PRESENTATION LOGIC IN THE HTML. You can modularise. You can ... test! Its
amazing. IT WILL ENABLE YOU TO STRUCTURE REALLY REALLY BIG PROJECTS! I hear
similar evangelism from the knockoutJS community, so I am keen to try that out
too, although I am getting pretty proficient with AngularJS and I personally
think its got more chance of survival given its googly backers, and its more
likely that chrome will start supporting AngularJS features natively. So I am
betting on longevity as well as functionality with NG.

~~~
aerolite
Ugh, but this is just terrible:

<input type="checkbox" ng-model="todo.done">

I guess I'm a purist.

~~~
joshuacc
What about it do you find terrible? The declarative nature of the binding? Or
just the fact that it isn't valid according to the HTML spec?

~~~
aerolite
It's invalid HTML and it's destroying the separation between logic and
presentation/content.

------
Cthulhu_
The actual 0.9.10 changelog is at <http://backbonejs.org/#changelog>

