If I hadn't left my previous job, It would take me a day or two to upgrade. Even Rails 3.2 => 4 is more straightforward.
If I hadn't left my previous job, It would take me a day or two to upgrade. Even Rails 3.2 => 4 is more straightforward.
* 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?
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.
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.
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.
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 ;)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.
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.
https://github.com/jashkenas/backbone/commit/51eed189bf4d258...
and the pull request:
Any change that renders my entire application broken should be a major version bump.