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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

call function from external JS-lib

feil
11-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
feil
11-Garnet
(To:sdidier)

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
sdidier
17-Peridot
(To:feil)

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

feil
11-Garnet
(To:sdidier)

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!

Top Tags