Solved

Using jquery UI with npm

Posted on 2016-07-30
3
1,799 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The viewer will learn how to dynamically set the form action using jQuery.
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.

695 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