Skip to end of metadata
Go to start of metadata


GateIn JQuery

This section provides an overview of JQuery stuff embedded by default in GateIn.

JQuery Core

The built-in JQuery Core is declared in a JavaScript resource named jquery with SHARED scope. The resource consists of two script entities jquery and exo-jquery-alias.

  • jquery wraps a version of JQuery Core
  • exo-jquery-alias wraps a JavaScript file defining custom alias

GateIn introduces the gj alias to deals with likely conflicts as real real production requires multiple versions of JQuery Core. With definition in exo-jquery-alias.js, that alias ensures following things:

  1. gj always refers to GateIn 's own JQuery Core, no matter how other JQuery versions are deployed into GateIn.
  2. As no extra JQuery Core version exists, the global variables $, jQuery are still active.
  3. As various JQuery Core versions exist, the global variables $, jQuery refers to the last JQuery Core instance loaded into client's browser (*)

Due to (*), we suggest that code depending on GateIn 's JQuery Core use gj alias instead of $ or jQuery.

JQuery Plugin

To embed a JQuery plugin depending on built-in JQuery Core, the best solution is to insert a <script> element into jquery resource as we can see in the sample with jquery_plugin_depending_on_1.7.1 plugin.

As the jquery_plugin_depending_on_1.7.1 script is placed before exo-jquery-alias, the entire plugin code is loaded/initialized with JQuery Core 1.7.1 before the two global variables $, jQuery are eventually deactivated by exo-jquery-alias.

Extra JQuery

In this section, we provide instructions on dealing with multiple versions of JQuery Core and JQuery plugins.

JQuery Core

Consider the circumstance where product owner has a portlet A working with JQuery Core 1.6.4 and they are forced to embed JQuery Core 1.6.4 due to certain conflicts between two versions 1.6.4 and 1.7.1. In this case, there are two solutions:

Declare a SHARED resource jquery-1.6.4 and make it a dependency of portlet A 's resource.

Define a module in portlet A 's resource that points to JQuery Core 1.6.4.

If jquery-1.6.4 has various dependents, it should be configured as SHARED resource and the first solution is encouraged.

JQuery Plugin

We assume that the portlet A in previous section need a plugin depending on jquery-1.6.4. It is expected to have the plugin code loaded/initialized with JQuery 1.6.4. There are two solutions as we can see in following configurations.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.