Solved

Using jquery UI with npm

Posted on 2016-07-30
3
1,259 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ModalPopup  question 22 39
Display field if column exists 7 35
assigning javascript variable to php variable 8 43
ASP.NET data base connection 35 43
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

726 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