inject js library with `Backbone.use(myLib)` #606

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

twobitfool commented Sep 11, 2011

I ran into an issue where the Backbone views were unable to pick up the javascript library I was using (Zepto), because of the way that browserify changes the scope to support require('backbone') in the browser -- it looks like ender suffers from the same issue. This would also make it easier to test views outside of the browser by injecting a mock jQuery library.

Owner

jashkenas commented Sep 14, 2011

This seems like a way to hack around the real problem. Let's try either fixing browserify so that the scope is still correct ... or fixing Backbone so that it can find a browserify'd Zepto.

@jashkenas jashkenas closed this Sep 14, 2011

Contributor

twobitfool commented Sep 15, 2011

@jashkenas: The browserify issue aside, I think this change would be worthwhile just because it let's people choose their own library. It certainly doesn't seem to add any significant overhead to the codebase, and it offers a little dependency injection, and that almost always results in more flexible and test-friendly software.

Maybe I'm just not seeing a better alternative, but without this change, how would someone unit test their views (without clobbering jQuery in the global namespace)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment