Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triggering custom event through script not working #70

Open
vibhu-imaginea opened this issue Aug 24, 2017 · 10 comments
Open

Triggering custom event through script not working #70

vibhu-imaginea opened this issue Aug 24, 2017 · 10 comments

Comments

@vibhu-imaginea
Copy link

I have a series of steps (say 5 steps), last two of which are asynchronous. So, I am giving custom event for last two steps. Now, I am not able to trigger the last two steps manually. Also I am getting the 4th step which should not be triggered until triggered manually. Any idea? The error I get after 4th step is rendered is:

Uncaught TypeError: Cannot read property 'left' of undefined

Here is the sample steps config:

var enjoyhint_script_steps = [{ "click #btn1": "Some Instruction.", "showSkip": showSkip, "showNext": showNext }, { "click [name='btn2']": "Some Instruction", "showSkip": showSkip, "showNext": showNext }, { "click .btn3": "Some Instruction", "showSkip": showSkip, "showNext": showNext }, { "event_type": "custom", "event": "my-custom-event1", "selector": "[name='btn4']", "description": "Some thing here", "showSkip": showSkip, "showNext": showNext }, { "event_type": "custom", "event": "my-custom-event2", "selector": "[name='btn5']", "description": "More instructions", "showSkip": showSkip, "showNext": showNext }];

var enjoyhint_instance = new EnjoyHint({});
enjoyhint_instance.set(enjoyhint_script_steps);
enjoyhint_instance.run();

showSkip and showNext are boolean variables set to false.

This is how I am triggering custom events on some event:
enjoyhint_instance.trigger('my-custom-event1');

@SGE66
Copy link

SGE66 commented Apr 11, 2018

Hi,

did you manage to solve this issue ? I'm having the same issue...

@jagers
Copy link

jagers commented Apr 23, 2018

Even though the docs say enjoyhint_instance.trigger('custom_event_name'); should work, I'm looking at the source code and it appears that the only values that will do something are trigger('next) and trigger('skip'). So the way I got a "custom" event to work was to set the event to custom and then calling enjoyhint_instance.trigger('next') when appropriate.
e.g.

var enjoyhint_script_steps = [
  {
    'custom .new_btn' : 'Waiting for a custom event to trigger'
  }  
];

function iAmReady()
{
  enjoyhint_instance.trigger('next');
}

Hope that helps

@phant0mstrife
Copy link

jagers it right about the code only run with 2 case ('next' and 'skip') in trigger event.

I came up with the solutions add custom case to trigger event and run to next step with nextStep() function.

that.trigger = function (event_name) {
switch (event_name) {
case 'next':
nextStep();
break
case 'skip':
skipAll();
break
default :
nextStep();
break;
}
};

Hope this help.

@mobilizecloud
Copy link

Still experience this issue. Any way to jump to a specific step based on trigger?

@zapper59
Copy link

zapper59 commented Aug 9, 2018

I've got custom steps working in this fork: https://github.com/darron1217/enjoyhint.js
It's a bit different so be sure to look at the example I put in that README

@zapper59
Copy link

zapper59 commented Aug 9, 2018

As far as skipping to a specific step give me until tomorrow and I can post the changes I had to make on the project I'm working on. It requires some specific changes to the rerunscript function

@Ciampije
Copy link

Ciampije commented Mar 5, 2019

Any update on skipping to a specific step?

@zapper59
Copy link

zapper59 commented Mar 5, 2019

My pull request #103
Has rerunscript(step) working correctly.

@Ciampije
Copy link

Ciampije commented Mar 7, 2019

Awesome thank you. I see it hasn't been merged into xbsoftware/enjoyhint. Is there a repo I can pull to get these latest changes?

@zapper59
Copy link

zapper59 commented Mar 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants