I work quite a lot with JQueryUI 1.8 lately, so time has come to create a new CB plugin. The JQueryUI Plugin handles (core)JS dependencies and CSS links for you, so no CFHTMLHEADs in your views anymore to include the proper files. You can just write:
jQueryUI = getPlugin("JQueryUI",true);
...or to enable multiple widgets at once:
What about effects and adding different ones along your code? Well, you can keep adding them and the plugin handles the boring stuff for you.
// other code
// other code
Adding interactions is rather simple as well. The following enables 'droppable and sortable' and includes the proper core JS files for you.
What if you only need one specific core file only?
If you want to know which effects/widgets are supported by the plugin, you could use CFDUMP e.g.
Ok, we're almost done. What if you want to add your own CSS file which overrides style definitions from the core CSS?
...which is exactly the same as:
As you noticed in the code above, we used an attribute 'renderPosition'. this attribute gives you control over the order how the CSS links are rendered. Having control over the rendering order is rather important for JS files (Thanks bro Tom de Man
for notifying......or 'G. Ramsey' for the insiders). So let's say you have a couple of JS files which you're adding along your code and you want the last JS file being rendered as first.
jQueryUI.setCustomJsLink(src='includes/js/myfile3.js',renderPosition=( arrayLen(jQueryUI.getCustomJsLinks() )-1 ));
// first position
Ok, all features discussed. Still interested?...let's set everything up.
- Grab the JQueryUI plugin from RIAForge and place it into your plugin folder
- Download jqueryui 1.8.1, unzip it into your includes folder (See screenshot below)
- Add the following lines to your coldbox config file
<!-- Path to jQueryUI library, e.g. includes/jqueryui -->
<setting name="JQueryUIPlugin.baseRelativePath" value="includes/jQueryUI" />
<Setting name="JQueryUIPlugin.cssRelativePath" value="includes/jQueryUI/themes/ui-lightness" />
<Setting name="JQueryUIPlugin.jsRelativePath" value="includes/jQueryUI/ui/minified" />
<Setting name="JQueryUIPlugin.jsFileNameSuffix" value=".min" />
- Place this code somewhere in your layout file. This renders the output of the plugin.