Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
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?
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.
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();
};