Solved

Using jquery UI with npm

Posted on 2016-07-30
3
729 Views
Last Modified: 2016-08-11
HI,
I installed jquery-ui using the command
npm install jquery-ui --save
And included it into my javascript file like :
var $ = require("jquery"), require("jquery-ui");
But on calling $("#dialog").dialog({ autoOpen: false });
I am getting the following error on console :
TypeError: $(...).dialog is not a function
$("#dialog").dialog({ autoOpen: false });
new.js (line 56, col 6)

what could be the reason for this ?
How to use jquery-ui ?
I am using webpack in my application to bundle modules.

Thanks
0
Comment
Question by:Rohit Bajaj
  • 2
3 Comments
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 41736428
Shouldn't be this way?
var $ = require("./jquery"), require("./jquery-ui");

Open in new window

0
 

Author Comment

by:Rohit Bajaj
ID: 41736665
Hi,
./jquery will look for jquery file in current directory whereas i am using it through npm.
require(jquery) works fine... only problem when is when i include jquery-ui which ideally should have dialog function things dont work somehow..
0
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 500 total points
ID: 41736716
Mybe you have to edit your webpack.config.js? I found that you have to add this:
resolve : {
    alias: {
      // bind version of jquery-ui
      "jquery-ui": "jquery-ui/jquery-ui.js",      
      // bind to modules;
      modules: path.join(__dirname, "node_modules"),
    }
}

Open in new window

Full answer here: http://stackoverflow.com/questions/33998262/jquery-ui-and-webpack-how-to-manage-it-into-module
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question