Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use jquery ui with bower?

Tags:

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!

like image 693
cremersstijn Avatar asked Apr 29 '13 17:04

cremersstijn


People also ask

How to install jQuery using Bower?

Libraries are downloaded with Bower using the bower install command. To install jQuery UI, run bower install jquery-ui . Doing so creates the following (simplified) directory structure. Note: If you get an error that the bower command is not found, check out Bower's installation instructions.

What is Bower used for?

Bower provides hooks to facilitate using packages in your tools and workflows. Bower is optimized for the front-end. If multiple packages depend on a package - jQuery for example - Bower will download jQuery just once. This is known as a flat dependency graph and it helps reduce page load.


1 Answers

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.

like image 86
hiroshi Avatar answered Oct 25 '22 11:10

hiroshi