Trigger change event on checkbox and radio button when checked state is changed

This commit is contained in:
Vasily Reys 2011-05-27 23:32:12 +06:00 committed by Joe Ferris
parent d7f491d7e0
commit 465e5edb12
2 changed files with 3 additions and 2 deletions

View File

@ -467,12 +467,12 @@ describe Capybara::Driver::Webkit do
it "triggers radio input events" do
subject.find("//input[@type='radio']").first.set(true)
subject.find("//li").map(&:text).should == %w(click)
subject.find("//li").map(&:text).should == %w(click change)
end
it "triggers checkbox events" do
subject.find("//input[@type='checkbox']").first.set(true)
subject.find("//li").map(&:text).should == %w(click)
subject.find("//li").map(&:text).should == %w(click change)
end
end

View File

@ -105,6 +105,7 @@ Capybara = {
} else if(type == "checkbox" || type == "radio") {
node.checked = (value == "true");
this.trigger(index, "click");
this.trigger(index, "change");
} else {
node.value = value;
}