cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Including a Javascript library shared between widgets

dclayworth
1-Newbie

Including a Javascript library shared between widgets

We want to create multiple widgets in an extension, all of which reference a Javascript library (specifically JQuery UI in this case, but we would like a general solution).

How can we package an extension so that all the widgets reference this library?

If we include the same JS library in multiple widgets will this break the extension?

2 REPLIES 2

Create a Widget with the library, and then on the documentation say that the other widgets depends on this one. All will be executed on the same context.

qn
1-Newbie
1-Newbie
(To:CarlesColl)

I added a library JS to "metadata.xml. But I can't call the function from the new library. For example, with this library http://www.jqueryscript.net/other/jQuery-Plugin-To-Generate-Animated-Dynamic-Gauges-dynameter.html.

I tried this in .runtime.js:

this.afterRender = function () {

        var self = this;

var domElementId = this.jqElementId;

var widgetElement = this.jqElement;

gaugeDynaMeterElementId = domElementId + '-widget-gaugeDynaMeter-container';

        gaugeDynaMeterEl = $('<div id="'+ gaugeDynaMeterElementId +'"></div>');

        widgetElement.append(gaugeDynaMeterEl);

      

        var gaugeResult;

        var gaugeDom = $("div#" + gaugeDynaMeterElementId);

      

        $(function(){

        gaugeResult = gaugeDynaMeterElementId.dynameter({

            width: 200,

    label: 'Voltage',

    value: 280,

    min: 0.0,

    max: 300,

    unit: 'V',

    regions: {

    235.0: 'warn',

    250.0: 'error'

    }

            });

        });

            

      

    bindToolTip();

    };

Top Tags