question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Binding to events with Context not working

See original GitHub issue

context is undefined in following code:

var PUSHER_APP_KEY = '...';
var pusher = new Pusher(PUSHER_APP_KEY);
var channel = pusher.subscribe("test-channel-x");
var context = { title: 'Pusher' };
var handlerSucess = function() {
  alert("Subscription succeded with " + this.title);
};
channel.bind("pusher:subscription_succeeded",handlerSucess ,context);

var handlerNew = function() {
  alert("new event with " + this.title);
};

channel.bind("new",handlerNew ,context);

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jackfranklincommented, Apr 28, 2016

As a work around for now, you could do:

channel.bind(..., handlerSucess.bind(context)

But we should get this fixed. Thanks for letting us know. Are you on PusherJS V3?

0reactions
alex-alfarocommented, May 7, 2016

No, it was Firefox 46 on Windows 10

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does the data binding not work when i set the data ...
In the buttonSave_Click handler, create and set the correct DataContext object (based on provided user input) then call BindingGroup.
Read more >
The "event" binding - Knockout.js
The event binding allows you to add an event handler for a specified event so that your chosen JavaScript function will be invoked...
Read more >
Events | Maps JavaScript API - Google Developers
MVC events, for example, do not pass arguments within their event. ... API provides the addDomListener() static method to listen to and bind...
Read more >
Azure Event Hubs output binding for Azure Functions
This article explains how to work with Azure Event Hubs bindings for Azure Functions. Azure Functions supports trigger and output bindings ...
Read more >
ReactJS | Binding Event Handlers - GeeksforGeeks
In ReactJS, we need to bind events so that the this keyword would not return an “undefined“. In this article, we are going...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found