How to install fastclick with ember-cli?

I have an ember-cli project. I used bower to install fastclick and added it to my broc file.

Now I'm trying to initialize it. In my app.js file, I added:

 import FastClick from 'bower_components/fastclick/lib/fastclick'; 

But this gives me an error in the console: "Uncaught TypeError: Unable to read the" default "property from undefined". The inspector shows the following generated code:

 ["ember","ember/resolver","ember/load-initializers","bower_components/fastclick/lib/fastclick","exports"], function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) { "use strict"; var Ember = __dependency1__["default"]; var Resolver = __dependency2__["default"]; var loadInitializers = __dependency3__["default"]; var FastClick = __dependency4__["default"]; # chrome highlights this line 

I assume the problem is that fastclick is not compatible with the ES6 bootloader that uses ember-cli. I don't have requirejs, so how can I install fastclick in my project? Docs are at https://github.com/ftlabs/fastclick .

I also tried adding this to index.html, but this has no effect when I create an iOS application:

  $(function() { FastClick.attach(document.body); }); 
+5
source share
3 answers

With Ember-cli v0.0.42

Install fastclick with bower

 bower install fastclick --save 

In your Brocfile.js add the following module.exports = app.toTree();

 app.import('bower_components/fastclick/lib/fastclick.js'); 

Then in app.js you can add

 var App = Ember.Application.extend({ ... ready: function(){ FastClick.attach(document.body); } }); 

You also need to add "FastClick":true to your preliminary .jshintrc file files to prevent it from complaining. For more information, see Dependency Management documents.

+9
source

You can also use ember-cli-fastclick :)

+4
source

OK, the jquery version does not work, but the following was indicated in the index.html file:

 window.addEventListener('load', function() { FastClick.attach(document.body); }, false); 
0
source

Source: https://habr.com/ru/post/1202759/


All Articles