Anyone get the gotoStepNoElement.js to actually work with a delay?

I'm trying to get one of my tours to skip a step if a specific dialog is not visible.

In the step, I've added the gotoStepNoElement.js code (from https://github.com/pendo-io/snippets/blob/master/guides/goToGuideStep/goToStepNoElement/), but I'm trying to add in a delay.

The code includes this:

/* If you must defer this to guide load time or if the element is not already visible
  pendo._.defer(function(){setTimeout(function checkElementAndSkip() {*/

I've uncommented the line, as thus:

/* If you must defer this to guide load time or if the element is not already visible */
  pendo._.defer(function(){setTimeout(function checkElementAndSkip() {

But:

1. This causes a JS error

2. I don't see where to add a delay of XXX seconds.

Anyone know what I'm doing wrong?

0

Comments

3 comments
  • Rick Sapir My team made some changes to the code and it worked. I am attaching that variation of the code below. If this code is added in a step with no UI elements, it starts appearing as a blank step during the delay. To counter that, we just made the background transparent so it is not visible on the users' screens. 
    Hope this helps!

    (function goToStepNoElement() {
      // Warning: .getPositionOfStep() is 1-based
      var nextStep = guide.steps[guide.getPositionOfStep(step)];

      // The step of your guide you would like to go to when the element of the subsequent step isn't present
      var desiredStep = 11; //<--Step number as displayed in Pendo

      /* If you must defer this to guide load time or if the element is not already visible */
      pendo._.defer(function () {
        setTimeout(function checkElementAndSkip() { // This code was incomplete in the Pendo snippets. A line of code was added at the end to complete it and add delay.
            
         /* (function checkElementAndSkip() { - Line in Pendo code snippet that was redundant (when the delay code is uncommented). Can be removed */
          var results = pendo.Sizzle(nextStep.elementPathRule);
          if (results.length === 0 || !pendo._.some(results, pendo.isElementVisible)) {
            pendo.log(guide.id + ':advance to designated step');

            // Use the line below if you don't want to utilize the Step ID directly and would rather use the step count
            pendo.goToStep({destinationStepId: pendo.getActiveGuide().guide.steps[desiredStep - 1].id});

            // Use the line below if you know the specific Step ID (generally a stronger reference)
            //pendo.goToStep({destinationStepId: "N9d7QgG8ZxOBqeUmZr4dn92yltE"});  <-- Example Step ID
          } else {
            pendo.log(guide.id + ':advance 1 step');
            pendo.onGuideAdvanced();
          }
        }, 1500) //This code was added. The number denotes delay time in milliseconds
      });
    })();
    1
  • Hi, I also had trouble with the code as is , we had to // out the line directly below the defer function (essentialy switching them) and THEN we had to add a

     }, 1500)

    later on like in the comment above. Not sure why that wasn't included in the github documentation.

    0

Please sign in to leave a comment.

Didn't find what you were looking for?

New post