I'm developing a node library that depends on jQuery and jqueryUI. I use browserify to make it accessible to a browser page.
So in my library code, there can be for example such kind of code:
var createMenu = function (target, options) {
$target = $(target);
$target.menu(options);
}
I require jQuery and jQueryUI like this:
var $ = jQuery = require("./node_modules/jquery");
require("./node_modules/jquery-ui-dist");
but when I call createMenu
function in the browser, it logs TypeError: $target.menu is not a function
.
JQueryUI doesn't seem to be properly loaded but I didn't find documentation on how to load it properly.
I also tried $.ui = require('./node_modules/jquery-ui/ui/widget.js')
without any more luck.
If I do the following:
jQueryUI = require("./node_modules/jquery-ui")
console.log(jQueryUI)
it only logs an empty object.
Any idea on the proper way to log jQueryUI to use it in nodejs?
These steps should work:
Install these packages from npm
npm install jquery
npm install jquery-ui-dist
Import them in HTML file, like
<script src="/node_modules/jquery/dist/jquery.min.js"></script>
<script src="/node_modules/jquery-ui-dist/jquery-ui.min.js"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With