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

slickness.not is not a function webpack build #131

Open
bellsenawat opened this issue Jun 1, 2017 · 7 comments
Open

slickness.not is not a function webpack build #131

bellsenawat opened this issue Jun 1, 2017 · 7 comments

Comments

@bellsenawat
Copy link

ERROR


TypeError: slickness.not is not a function
    at angular-slick.js:167
    at angular.js:20178
    at completeOutstandingRequest (angular.js:6274)
    at angular.js:6554

app.js


window.jQuery = require('jquery');
var bootstrap = require('bootstrap/dist/js/bootstrap');
var slick = require('slick-carousel');

import angular from 'angular';
import slickCarousel from 'angular-slick-carousel';

webpack.config.js


 entry: {
    app: ['babel-polyfill', path.join(__dirname, 'src', 'app/root.module.js') ],  
  },
new webpack.ProvidePlugin({
        jQuery: 'jquery',
        $: 'jquery',
        jquery: 'jquery',
  }),
 new HtmlWebpackPlugin({
      template: 'src/public/index.ejs',
      inject: 'body',
      hash: true,
      chunks: ['app']
   }),

Work around :
Just replace this to header of index.html

<script src="/lib/jquery-2.2.4.min.js"></script>    
<script src="/lib/slick.min.js"></script>

But I dont' want to loading more files.

Please advise me

@svindler
Copy link

I had the same problem.

Put this to my webpack config:

new webpack.ProvidePlugin({
'window.jQuery': 'jquery',
'windows.&': 'jquery'
});

And this as my first import before angular:

import {$,jQuery} from 'jquery';
window.$ = $;
window.jQuery = jQuery;

@ghost
Copy link

ghost commented Nov 15, 2017

That's because angular-slick-carousel depends on slick-carousel.

You need to install it first:
https://www.npmjs.com/package/slick-carousel

Then import it in your app:

import slickCarousel from 'slick-carousel';

@heshamelmasry77
Copy link

not working
screen shot 2017-12-04 at 10 49 34 pm

@ohabash
Copy link

ohabash commented Dec 15, 2017

none of this works. this is going on 2 days. help!.... the only solution I am not sure I tried is new webpack.ProvidePlugin({ because i dont know how it fits in webpack.config.js... Can someone explain to a beginner the how and whys of that solution? THank you!

@ghost
Copy link

ghost commented Feb 27, 2018

Hi,

had the same problem, it's connected to angular.element() VS $(), as soon as i changed the line 143 of angular-slick.js, all worked fine.
The problem is at line 167, were "slickness.not()", this function on selected element does not exist angular.element().not().

here's what i changed to get it to work:
Line 140.
init = function () {
initOptions();

        var slickness = $(element); // VS var slickness = angular.element(element);

This is true for "angular": "^1.6.6", don't know if the ".not()" existed before or not, But on this jQueryLite version of this angular@1.6.6 it does not exist.

Don't know who or how this directive was tested, but this seems like an error everybody should have unless as i stated before, the ".not()" method existed before.

Cheers.


UPDATE

Forgot to mention, you also have to change this line (same concept)
Line 131.
destroy = function () {
var slickness = $(element); //angular.element(element);

@peterfiorito
Copy link

as @pjsalsantos said, angular works with jqlite; Even with jquery loaded in the project, .not() used inside the directive will bring problems.
Just replace angular.element() with jquery's $(element).. or alternatively, refactor the code to avoid using the .not() property.
This will solve the issue.

@EvanLomas
Copy link

To fix this issue in the mean time, load JQuery BEFORE Angular so angular uses the full JQuery library
ie if you are using a cdn method:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
...
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.10/angular.js"></script>
...
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-slick-carousel/3.1.7/angular-slick.js"></script>

This way Angular replaces the jquery-lite library inside angular.element() with the full jquery equivalent of $() as documented here:
https://docs.angularjs.org/api/ng/function/angular.element#overview

If you use a bundling system, check the documentation for ordering your scripts in a similar manner

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

6 participants