Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
Call function without actually executing it

So I have such a weird question and I don't know if this is possible, but I will give it a shot anyways.

We have implemented OneTrust, which is a third-party cookie consent vendor and it works great and all, but we have one small hiccup that we are trying to resolve.

So within the below function:

  toggleVideo: function (videoWrapper, src, cover, type, element) {
    var videoElement = video.buildVideo(src, type);

    // We build out video-player element
    videoWrapper.html(videoElement);

    // We define our variables
    let onetrust = window.OneTrust;
    let onetrust_obj = window.ONETRUST_MODULE;
    let target = videoWrapper.html(videoElement).children('iframe');

    console.log(onetrust.Close());

    // Now we wait and observe for a src attribute and then show the video.
    onetrust_obj.src_observer(target, function() {
      video.toggle_show(videoWrapper, cover);
    });
  },

We have an <iframe> element that when clicked play, will wait for consent to execute - The problem is that it needs to "refresh" OneTrust so that it can change the data-src to src attribute (This is all handled using OneTrust JS, so I have no control).

  1. When I add in the console.log(onetrust.Close());, it works just as intended and resumes playing the video when consent is given, the downfall is that it outputs an error in the console. If I remove it, the videos will not play after consent is given.
  2. I don't want to actually execute the onetrust.Close() method as it will close the banner.
  3. OneTrust doesn't have a proper way to "Refresh" their initialization, the techs told me that this was a one-off case, where they don't even know how to handle it.

My questions:

  1. Is there a way that I can properly call onetrust.Close() (Seems to be the only call that actually engages the video to play after) without actually executing it?
  2. If not, is there a way that I can somehow similarly log it, but not actually log it in the console?

Thanks all!

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

Strange one, may be a race-condition issue so making your code run in the next procedural iteration may resolve the issue - this can be done by adding a setTimeout with no timer value.

setTimeout(() => {
  onetrust_obj.src_observer(target, function() {
    video.toggle_show(videoWrapper, cover);
  });
});

Alternatively, it may be worth digging into the onetrust.Close() method to see if there are any public utilities that may help 'refresh' the context you are working in.

Another idea would be to see what happens after if you ran the onetrust_obj.src_observer code block again.

EDIT: I would like to be clear that I'm just trying to help resolve debugging this, without seeing a working environment it's difficult to offer suggestions ๐Ÿ˜„

about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!