You are looking at documentation for an older release. Not what you want? See the current release documentation.
This section shows you how to configure a jQuery plugin and how to use it in the
jQueryPluginPortlet
portlet.
(function($) { $.fn.doesPluginWork = function() { alert('YES, it works!'); }; })(jQuery);
Declare it as a module:
<module>
<name>jquery-plugin</name>
<as>jqPlugin</as>
<script>
<path>/jqueryPlugin/jquery-plugin.js</path>
</script>
<depends>
<module>jquery</module>
<as>jQuery</as>
</depends>
</module>
Use this plugin in your portlet:
<portlet>
<name>jQueryPluginPortlet</name>
<module>
<script>
<path>/jqueryPlugin/jqueryPluginPortlet.js</path>
</script>
<depends>
<module>jquery</module>
<as>$</as>
</depends>
<depends>
<module>jquery-plugin</module>
</depends>
</module>
</portlet>
Your portlet module should depend on the jquery and you need to declare:
The dependency on
jquery
that allows using the jQuery object.
jquery-plugin
that ensures the plugin to be loaded in the
jquery
dependency before it is injected in the portlet module.