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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

call function from external JS-lib

feil
12-Amethyst

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?

ACCEPTED SOLUTION

Accepted Solutions
feil
12-Amethyst
(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
12-Amethyst
(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!

Announcements

Top Tags