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

Event callback signature in docs #2

Closed
maxkfranz opened this issue Jun 21, 2016 · 3 comments
Closed

Event callback signature in docs #2

maxkfranz opened this issue Jun 21, 2016 · 3 comments
Assignees

Comments

@maxkfranz
Copy link

cy.on("afterExpand", function(node) { }) should be cy.on("afterExpand", function(event) { var node = this; ... })

@selimfirat
Copy link

It would be better, thanks but there is a minor issue.
Now, cy.nodes().on("afterExpand", function(event) { var node = this; ... }) works properly but cy.on("afterExpand", function(event) { var node = this; ... }) this value is not a node. It is a scope including _private & one of my variables.

I am using node.trigger("afterExpand") to emit event. I also tried cy.trigger.call(node, "afterExpand) but result was the same.

@maxkfranz
Copy link
Author

Typo: cy.on("afterExpand", function(event) { var cy = this; ... })

If you want the node, you have to bind directly to the node or use a delegate selector.

I've confirmed this working fine in the console:

cy.on('foo', 'node', function(e){ console.log( e, this ) });
Core {_private: Object}
cy.nodes()[0].trigger('foo')
VM488:1 Event {originalEvent: Object, type: "foo", cy: Core, cyTarget: Element, cyPosition: undefined…} Element {0: Element, length: 1, _private: Object}
Element {0: Element, length: 1, _private: Object}

@selimfirat
Copy link

After the commit above, it works now as expected.

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

3 participants