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

ReferenceError: event is not defined in FireFox #184

Open
DennisKh opened this issue Feb 28, 2019 · 9 comments
Open

ReferenceError: event is not defined in FireFox #184

DennisKh opened this issue Feb 28, 2019 · 9 comments

Comments

@DennisKh
Copy link

ReferenceError: event is not defined
exec_elixir http://local.com/:187
event_handler_function http://local.com/:1021

I use {:drab, "~> 0.10.1"}
Explain what's wrong. Everything works in Chrome.

@DennisKh
Copy link
Author

DennisKh commented Mar 1, 2019

Has fixed it as follows. Works for me for now but it's not a right solution.

exec_elixir: function (event_handler, payload, execute_after) {
      var reply_to = did();
      if (!(payload !== null && typeof payload === 'object' && Array.isArray(payload) === false))
        payload = {payload: payload};
      var p = {};
      for (var i = 0; i < Drab.additional_payloads.length; i++) {
        var fx = Drab.additional_payloads[i];
/////////////// My code
        var event = event
        if (typeof(event) == "undefined") {
          event = new Event('click');
        }
//////////////
        p = Object.assign(p, fx(null, event));
      }
      payload = Object.assign(p, payload);
      if (execute_after) {
        Drab.event_reply_table[reply_to] = execute_after;
      }
      var message = {
        event_handler_function: event_handler,
        payload: payload,
        reply_to: reply_to
      };
      this.channel.push("event", message);
    }

@grych
Copy link
Owner

grych commented Mar 6, 2019

Thanks, this the well noted!

@albaer
Copy link

albaer commented Mar 6, 2019

👍 I'm also running into this in Firefox. Are you looking for any help on a fix?
And thanks for all the great work on Drab! It's a ton of fun to use.

@albaer
Copy link

albaer commented Mar 6, 2019

In case this is helpful, looks like it is from this commit and the fact that Firefox has the global event variable behind a flag: https://developer.mozilla.org/en-US/docs/Web/API/Window/event.

@grych
Copy link
Owner

grych commented Mar 7, 2019 via email

@albaer
Copy link

albaer commented Mar 7, 2019

Awesome! Thanks for the quick fix and for all your other work on Drab.

@DennisKh
Copy link
Author

Thank you for the quick fix!

@marisradu
Copy link

Hi @grych

You already have an event in the payload, at least if the error appears after a "drab-click" event.
Sorry that I did not had time to look thru the code to see how and when that is added to the payload and if it's added to all calls to exec_elixir, but might worth to extract the event from the payload if available first, then fallback to the "new Click" workaround provided by @DennisKh .

Cheers and thank you for all your great work on Drab,
Radu

@grych
Copy link
Owner

grych commented Apr 11, 2019

Hi @marisradu,
what do you mean by that?

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

4 participants