Skip to main content
1-Visitor
August 20, 2019
Solved

call function from external JS-lib

  • August 20, 2019
  • 1 reply
  • 1956 views

Hi.

Currently I'm trying to call a function from an external JS-lib. (tooltip.js)

I managed to load the JS-File via 

twx.app.fn.loadResourceScript('Uploaded/tooltip.js');

as mentioned here

https://community.ptc.com/t5/Vuforia-Studio/Including-js-file-from-resources/m-p/556781#M3480

 

But unfortunately I'm getting an  ReferenceError: Tooltip is not defined.

My function in home.js looks like this:

//Tooltips
$scope.createTooltips = function(){
 var referenceElement = document.querySelectorAll('[widget-id="photoBtn"]');
 const instance = new Tooltip(referenceElement, {
 title: "Hey there",
 trigger: "click",
 });
 instance.show(); 
}

the function(variable) I want to use from external js (tooltip.js) looks like this.

var Tooltip = function () {
 function Tooltip(reference, options) {
 ...some code....
}

Someone has an idea?

Best answer by feil

My mistake.
I just saw that I load the JS-files after the model was initialised.

That's to late. 

Now it's working.

Thanks!

1 reply

17-Peridot
August 20, 2019

Hello feil Marble,

 

  • Where or when do you load the library with Javascript code ?
  • In Preview, in Developer toolbar, in Sources tab, do you see the javascript file related to tooltip.js loaded

 

Best regards,

Samuel

feil1-VisitorAuthorAnswer
1-Visitor
August 20, 2019

My mistake.
I just saw that I load the JS-files after the model was initialised.

That's to late. 

Now it's working.

Thanks!