How to use jquery ui with bower?

cremersstijn picture cremersstijn · Apr 29, 2013 · Viewed 29.2k times · Source

I'm experimenting with yeoman and bower.

I have created a yeoman webapp using the following command

yo webapp

I want to use jqueryui so I have installed it using bower:

bower install jquery-ui --save

This works fine, but the jQuery UI component doesn't contain a javascript file with "all" the components, it just contains a lot of javascript files, one for each component.

Should I include only the javascript files that I need? Or should I do something else before using jQuery UI?

Thanks for the tips!

Answer

hiroshi picture hiroshi · May 20, 2013

Added jquery-ui in dependencies of bower.json (or component.json) along with jquery.

{
  …,
  "dependencies": {
    "jquery": "~1.9.1",
    "jquery-ui": "~1.10.3",
    ...
  },
  …
}

Install them:

bower install

Then, added path to jqueryui In main.js and require it:

require.config({
  paths: {
    jquery: '../components/jquery/jquery',
    jqueryui: '../components/jquery-ui/ui/jquery-ui',
    …
  },
  shim: {
    jqueryui: 'jquery',
    …
  },
  …
});
require(['app', 'jquery', 'jqueryui', 'bootstrap'], function (app, $) {
  'use strict';
   ...
});

It works for me.