M
M
Masterstvo2017-05-16 18:49:02
Node.js
Masterstvo, 2017-05-16 18:49:02

How to connect jQuery and jQuery UI (or another library using jQuery) at the same time when working with modules (npm)?

Good afternoon!
Can't connect and use jQuery UI. Sample code below:

var $ = require('jquery');
var ui = require('jquery-ui');

$('#id').slider();

If you connect through scripts in html, everything naturally works.
I use gulp to build, inside it to build gulp-webpack js files, as follows:
gulp.task('scripts', () => (
  gulp.src('app/slides/index.js')
    .pipe(plumber({errorHandler: errorHandler}))
    .pipe(changed(paths.scripts))
    .pipe(babel())
    .pipe(webpack())
    .pipe(rename((path)=>{
      path.basename = 'index';
    }))
    .pipe(gulp.dest(paths.scripts))
));

Does anyone know how to fix this problem? I will be grateful!!!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alex, 2017-05-16
@Masterstvo

var $ = require('jquery');
require('jquery-ui/ui/widgets/slider');

$('#id').slider();

A
Alexander Aksentiev, 2017-05-16
@Sanasol

may be

var window.$ = require('jquery');
var window.ui = require('jquery-ui');
$(function(){
    $('#id').slider();
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question