Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make project compatible with Backbone 1.1 and up #1

Open
PaulTondeur opened this issue Nov 10, 2013 · 3 comments
Open

Make project compatible with Backbone 1.1 and up #1

PaulTondeur opened this issue Nov 10, 2013 · 3 comments

Comments

@PaulTondeur
Copy link
Member

From version 1.1 and up, Backbone no longer uses the internal _configure method upon which we rely. Therefor the automatic injection that this library provides does no longer work.

@navFooh
Copy link

navFooh commented Aug 5, 2014

Hey Paul, all well in freelancer-life?

I also ran into this issue and this is my solution at the moment:

define(['backbone'], function(Backbone) {
    'use strict';

    Backbone.View = (function(View) {

        return View.extend({

            injector: 'inject',

            constructor: function(options) {
                options.injector.injectInto(this);
                View.apply(this, arguments);
            }

        });

    })(Backbone.View);

    return {};
});

Overriding the constructor instead of the _configure function seems the way to go.
The define is necessary to make it work well with r.js, else you'll get Backbone is undefined
Although I guess this needs to be modified to make it non-AMD compatible.

Could do a proper test pull-request for that later, just a quick fix for the moment :)

@PaulTondeur
Copy link
Member Author

Hi Thijs,
Great to hear from you and great you are still using the injector!
Awesome that you have sorted this out man! That is highly appreciated! Backbone works indeed differently in the newer versions. Both the constructor, but also the AMD behaviour.
Whenever I have time to allocate to this again I'll look into your suggestions. But feel free to make a pull request which supports both AMD and non AMD :-)
Paul

@navFooh
Copy link

navFooh commented Aug 6, 2014

My pleasure! Have been using the injector ever since and wouldn't want to miss it in Backbone :)
It also occurred to me that this implementation might conflict with other plugins that override the constructor..

Anyway I'm also quite slammed at the moment, we'll tidy this up in due time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants