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

call function from external JS-lib

SOLVED
Highlighted
Garnet

call function from external JS-lib

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: call function from external JS-lib

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!

View solution in original post

2 REPLIES 2
Highlighted

Re: call function from external JS-lib

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

Highlighted

Re: call function from external JS-lib

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!

View solution in original post

Announcements
Join an
AR Working Group!

Topics available:
AR/VR for Data Optimization AR/VR for Security and Control AR/VR for Inspection