Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How?

* Made the return values of Collection's set, add, remove, and reset more useful. Instead of returning this, they now return the changed (added, removed or updated) model or list of models.

Given that calling `collection.add(foo)` returned `collection`, when were you ever using the return value for anything? Going forward you might, but I would be very surprised if much if any code was broken by this.

* Backbone Views no longer automatically attach options passed to the constructor as this.options, but you can do it yourself if you prefer.

This might require going through your code base, but it's just adding one line in the `initialize` function:

    initialize: function(options) {
      this.options = options;
Annoying if you have hundreds of views that directly extend Backbone.View, but not something that should take a day to fix?

Am I missing something?




The return values change matters if you are chaining actions anywhere, which isn't that uncommon.

And yes, some people do have lots of views. In my current codebase we use Backbone.View as the base of all our frontend web components. This won't take us a day to update, but it's far from trivial, and we will have to regression test every component.


This should actually only take you 2 minutes if you'd like to keep the old behavior ... regardless of how many View classes you happen to have in your app. For example:

    var originalView = Backbone.View;
    Backbone.View = function(options) {
      var instance = new originalView(options);
      instance.options = options;
      return instance;
    };
Ahh..., isn't JavaScript just a lovely thing ;)


Sure you can hack things up like that. But when you use and update a library, you don't want to rely on deprecated behaviors.


Doh, completely whiffed on chaining. I can see that breaking in weird ways. Thanks for the insight.


> Am I missing something?

Well, I can't give you stats about the codebase anymore, but to give you an idea, the app was stated with Backbone 0.3, and contain between 2 and 3 hundred views, collections and models.

For the `.add` etc, it can seems straightforward, but when greping you will have a lot of noise from similar methods in other libs like jQuery.

The option is the real deal. Sure I can implement the behavior back. But I don't call that upgrading. If I upgrade I want my code to look like is was coded for the new version, not maintaining 3 years of hacks for backward compatibility.

So it mean that I have to grep hundreds and hundreds of `this.soptions.something` replace them by `this.something`and add `this.something = options.something`in the constructor.

It's a PITA.

And in fine I don't see the rationale for this removal, I failed to find the commit.



You're missing a lot, but you would have had to peruse the commits that have been happening over the past year to know how much has changed.

I'm not sure how to proceed with my own LayoutManager plugin. Hoping someone will PR a fix making it compatible, because my initial attempt told me it wasn't going to be trivial.


Looking into it, it seems like most of your issues stem from the fact that you depended on View._configure being called during initialization. You overwrite it here:

https://github.com/tbranyen/backbone.layoutmanager/blob/mast...

but this was completely removed with the update:

https://github.com/jashkenas/backbone/compare/1.0.0...1.1.0#...

In backbone's defense, that wasn't part of its public API, but it does make updating challenging. I'll give it a try and see if I can be of some help.


What are the issues you're seeing with LayoutManager? Are they reflected in the changelog or hidden in commit messages?


Yes, for that i prefer my own Namespace and extend not directly from Backbone (e.g. same when you use Backbone-Marionette).

Before you change your views, you should think about an own class on top of backbone and extend from that class.

So you can handle default behaviours easier and centralized.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: