I use requirejs with fastclick. I get the following error:
Uncaught TypeError: Cannot set property 'trackingClick' of undefined
in Fastclick.js line 30 which does: this.trackingClick = false;
In config.js I run app.js:
require.config({
paths: {
fastclick:'fastclick'
}
)};
require(['app'], function (App) {
App.initialize();
});
In my app.js
I do:
define(['fastclick'], function(fastclick){
var app = {
initialize: function () {
var attachFastClick = require('fastclick');
attachFastClick(document.body);
}
}
return app;
}
The browser starts fine and in the debugger the fastclick library is properly instantiated and resolved but still this
in the Fastclick.js cannot be resolved.
I also tried fastclick(document.body);
but it did not seem to have any effect.
Any ideas?
Looking through the Fastclick code I found the following functions which works:
Fastclick.attach
So, instead of calling:
var attachFastClick = require('fastclick');
attachFastClick(document.body);
The following works:
fastclick.attach(document.body);
In my app, I simply use the code seen below to properly initialize my app with fastclick. I removed all the other irrelevant lines of code to make my solution more clear
define([
'fastclick',
], function(FastClick){
var initialize = function(){
new FastClick(document.body);
}
return {
initialize: initialize
};
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With