usablica / intro.js

Lightweight, user-friendly onboarding tour library
http://introjs.com
Other
22.8k stars 2.59k forks source link

Option to disable the next button on a particular step #898

Closed hajimurtaza closed 3 years ago

hajimurtaza commented 5 years ago

Description

Disable next button on a particular step , in order to ensure user click the highlighted element and then continue the tour

Expected Behavior

For example i have highlighted search button on step 3, which takes me to a new page. I want to ensure user clicks on search button. Right now i am having to manipulate a lot as there are two options the user can take and its a nightmare to design based on predicting what user will do.

Actual Behavior

What actually happened?

Errors and Screenshots (optional)

image

Example (recommended)

i am going to the new page and starting tour from step 4 using goToStep function. But i cant go to the page unless user enters some value and clicks search button . if I could disable next button he would only be pressing search button which will ensure he reached the correct page

Environment (optional)

List browser information, Intro.js version, Operating System, JavaScript libraries (jQuery, Angular, React), etc.

daizeng1984 commented 5 years ago

+1 for all the individual step related features. If you like a workaround:

intro.onafterchange(function(targetElement) {  
  if(intro._currentStep == 2) { // your disabled step 2 for example
    var original_onclick = $('.introjs-nextbutton').get(0).onclick;
    $('.introjs-nextbutton').addClass('introjs-disabled');
    $('.introjs-nextbutton').get(0).onclick = null;
    $('#searchbox').on('search:done', function() {
      $('.introjs-nextbutton').removeClass('introjs-disabled');
      $('.introjs-nextbutton').get(0).onclick = original_onclick;
    }
...
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.