Created
February 7, 2012 11:38
-
-
Save clarkdave/1759281 to your computer and use it in GitHub Desktop.
ZombieJS ignoring jQuery $.delegate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <head> | |
| <title>ZombieJS test</title> | |
| <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script> | |
| </head> | |
| <body> | |
| <a href='#' id='clicker1'>Clicker one</a> | |
| <a href='#' id='clicker2'>Clicker two</a> | |
| <a href='#' id='clicker3'>Clicker three</a> | |
| <script> | |
| $(document).ready(function() { | |
| $('#clicker1').bind('click', function() { | |
| console.log('Clicked one'); | |
| }); | |
| $('body').delegate('#clicker2', 'click', function() { | |
| console.log('Clicked two'); | |
| }); | |
| // preferred way to do delegation in jQuery 1.7+ | |
| $('body').on('click', '#clicker3', function() { | |
| console.log('Clicked three'); | |
| }) | |
| }); | |
| </script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Zombie = require('zombie'); | |
| var browser = new Zombie(); | |
| browser.visit('http://localhost:8000', function() { | |
| browser.clickLink('Clicker one', function() { | |
| console.log('--> Callback fired for clicker one'); | |
| browser.clickLink('Clicker two', function() { | |
| console.log('--> Callback fired for clicker two'); | |
| browser.clickLink('Clicker three', function() { | |
| console.log('--> Callback fired for clicker three'); | |
| }); | |
| }); | |
| }); | |
| }); |
Author
Hi clack, where can I track the status of this issue ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In a browser, all three links in the
index.htmlwill fire when clicked.In the supplied ZombieJS test, only the first one (a direct bind) will actually fire. The other two will have their
clickLinkcallbacks executed within Node but they won't actually fire their browser callbacks (i.e. the only console.log statement to appear is that of the first link).