This repository has been archived by the owner on Dec 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix firing the
change
event on SELECT tags when using jQuery.
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require "./helpers" | ||
{ vows: vows, assert: assert, zombie: zombie, brains: brains } = require("vows") | ||
jsdom = require("jsdom") | ||
|
||
brains.get "/jquery", (req, res)-> res.send """ | ||
<html> | ||
<head> | ||
<title>jQuery</title> | ||
<script src="/jquery.js"></script> | ||
</head> | ||
<body> | ||
<select> | ||
<option>None</option> | ||
<option value="1">One</option> | ||
</select> | ||
<span id="option"></span> | ||
</body> | ||
<script> | ||
$(function() { | ||
$("select").bind("change", function() { | ||
$("#option").text(this.value); | ||
}); | ||
}); | ||
</script> | ||
</html> | ||
""" | ||
|
||
vows.describe("Compatibility with JavaScript libraries").addBatch( | ||
"jQuery": | ||
zombie.wants "http://localhost:3003/jquery" | ||
"selecting an option in a select element": | ||
topic: (browser)-> | ||
browser.select "select", "1" | ||
@callback null, browser | ||
"should fire the change event": (browser)-> assert.equal browser.text("#option"), "1" | ||
|
||
|
||
).export(module) |
This file contains 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
42f9edd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!
You might not remember it, because it was a long time ago, but actually, when you committed this, you asked me to help with writing tests for the other input types. Well, at that time I didn't have the time for that (learning coffeescript, writing mini-servers in node for serving up the tests, etc.), and yes, I was selfish, because all I needed that my code works (ie. the select element correctly fires the change), long story short, I didn't write those tests.
Neither did now.
Because I still haven't got the time.
Sorry for that.
But I can confirm, that the other input elements (but at least the "input type=text") also need it. Now I'm using zombie 0.9.4 with jquery 1.4.x and I had to edit (yes, by hand) the .npm/zombie/active/package/lib/zombie/browser.js file, line 321, in the "fill" function. The same change as above is enough, ie:
Sorry for being lazy and not committing back to the project. I promise when I have time, I'll do that first!
Cheers,
Bela
42f9edd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs a test case, code without tests gets lost (often the most silly edit mistake), breaking unexpectedly.