cancel
Showing results for 
Search instead for 
Did you mean: 

can i use javascript file with aikau page

janaka1984
Star Contributor
Star Contributor

Hi,

can i use javascript file with aikau page as like dashlet javascript file in aikau dashelt?

Regards

janaka

3 REPLIES 3

mitpatoliya
Star Collaborator
Star Collaborator

You can use javascript, even jQuery also can be used. You have one js file associated with your aiku widget where you can place your js logic.

Checkout this latest blog from Dave.

HI Mittal,

i read this blog from dave. i can use one common js file with aikau widget. but i have doubt whether we can use common JS to put logic.

Also extended custom widget (it contain following content )  does use to manage custom widget and logic that is specific to widget

e.g

define(["dojo/_base/declare",

        "dijit/_WidgetBase",

        "alfresco/core/Core",

        "dijit/_TemplatedMixin",

        "dojo/text!./HelloWorldTextWidget.html"

    ],

    function(declare, _Widget, Core, _Templated, template) {

        return declare([_Widget, Core, _Templated], {

ddraper
World-Class Innovator
World-Class Innovator

Each widget defines the specific JS modules that it is dependent upon. So in that example the widget is dependent upon:

  • dojo/_base/declare
  • dijit/_WidgetBase
  • alfresco/core/Core
  • dijit/_TemplatedMixin

Each of those JS files can declare their own dependencies. Surf will calculate the dependency tree for all widgets on the page and ensure that they are included in a single resource requested by the page when it is loaded.

There is nothing to stop any of the resources being shared between widgets - however, in the AMD pattern (and indeed any module based architecture) the widget needs to declare its dependencies in order to have access to them

However, this does not stop the widget from having access to any JavaScript code that is available at the global scope. However, it is more efficient to use a modular pattern because you only load the resources required for the page and therefore improve page performance.