Open daleyjem opened 11 years ago
You have to require hammer.backbone only once in your app, since it modifies your views. If you only require it in one view you will can get this error when trying to create other views which do not require backbone.hammer
I have the same problem, but only after I have run r.js to optimize the code. Could any of you post an example of how you load backbone.hammer?
I'm also getting this issue after using r.js. I managed to fix it after reading #4 . The basic idea is to load it before marionette so in my main file I have the following which appears to work:
requirejs(['backbone.hammer', 'app'], function (backbonehammer, app) {
app.start();
});
@blueo that should work but is still a bit of a crapshoot if app
depends on Marionette, which it presumably does.
The problem is that, although RequireJS should request 'backbone.hammer' before 'app', the responses will be asynchronous. So if the browser happens to receive and load 'app' first, Marionette.View
will be defined as a subclass of a "virgin" Backbone.View
, rather than the version of Backbone.View
that will be monkey-patched by backbone.hammer.
One way to ensure your app isn't loaded before backbone.hammer is to do something like this:
requirejs(['backbone.hammer'], function () {
requirejs(['app'], function (app) {
app.start();
}
});
Another way to avoid the issue would be to edit your copy of Marionette to add a 'backbone.hammer' dependency. But that's going to break the first time you upgrade Marionette...
Uncaught TypeError: Object [object Object] has no method 'undelegateHammerEvents'
Marionette Views extend Backbone Views, right? Do I have to configure my RequireJS deps/exports in some fashion?