});
test("live with change", function(){
+ expect(8);
+
var selectChange = 0, checkboxChange = 0;
var select = jQuery("select[name='S1']")
checkbox.trigger("change");
equals( checkboxChange, 1, "Change on checkbox." );
- // test before activate on radio
-
- // test blur/focus on textarea
- var textarea = jQuery("#area1"), textareaChange = 0, oldVal = textarea.val();
- textarea.live("change", function() {
- textareaChange++;
- });
-
- textarea.val(oldVal + "foo");
- textarea.trigger("change");
- equals( textareaChange, 1, "Change on textarea." );
-
- textarea.val(oldVal);
- textarea.die("change");
-
// test blur/focus on text
var text = jQuery("#name"), textChange = 0, oldTextVal = text.val();
text.live("change", function() {
textChange++;
});
- text.val(oldVal+"foo");
+ text.val(oldTextVal+"foo");
text.trigger("change");
equals( textChange, 1, "Change on text input." );
});
test("delegate with change", function(){
+ expect(8);
+
var selectChange = 0, checkboxChange = 0;
var select = jQuery("select[name='S1']");
checkbox.trigger("change");
equals( checkboxChange, 1, "Change on checkbox." );
- // test before activate on radio
-
- // test blur/focus on textarea
- var textarea = jQuery("#area1"), textareaChange = 0, oldVal = textarea.val();
- jQuery("#body").delegate("#area1", "change", function() {
- textareaChange++;
- });
-
- textarea.val(oldVal + "foo");
- textarea.trigger("change");
- equals( textareaChange, 1, "Change on textarea." );
-
- textarea.val(oldVal);
- jQuery("#body").undelegate("#area1", "change");
-
// test blur/focus on text
var text = jQuery("#name"), textChange = 0, oldTextVal = text.val();
jQuery("#body").delegate("#name", "change", function() {
textChange++;
});
- text.val(oldVal+"foo");
+ text.val(oldTextVal+"foo");
text.trigger("change");
equals( textChange, 1, "Change on text input." );
ok( !jQuery(window).data("__events__"), "Make sure all the events are gone." );
});
+test("focusin bubbles", function() {
+ //create an input and focusin on it
+ var input = jQuery("<input/>"), order = 0;
+
+ input.prependTo("body");
+
+ jQuery("body").bind("focusin.focusinBubblesTest",function(){
+ equals(1,order++,"focusin on the body second")
+ });
+
+ input.bind("focusin.focusinBubblesTest",function(){
+ equals(0,order++,"focusin on the element first")
+ });
+
+ input[0].focus();
+ input.remove();
+
+ jQuery("body").unbind("focusin.focusinBubblesTest");
+});
+
/*
test("jQuery(function($) {})", function() {
stop();