Skip to content

Commit 55ee6b1

Browse files
committed
Don't convert disabled fields in formParams. Closes #24
1 parent 1c69608 commit 55ee6b1

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

dom/form_params/form_params.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ steal("jquery/dom").then(function( $ ) {
131131
seen = {},
132132
current;
133133

134-
135-
this.find("[name]").each(function() {
134+
this.find("[name]:not(:disabled)").each(function() {
136135
var $this = $(this),
137136
type = $this.attr("type"),
138137
name = $this.attr("name"),

dom/form_params/form_params_test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,12 @@ test("#17 duplicate sub-keys", function() {
9191
console.log(formParams);
9292
});
9393

94+
test("#24 disabled elements", function() {
95+
$("#qunit-test-area").html("//jquery/dom/form_params/test/basics.micro",{});
96+
var formParams = $("#qunit-test-area form").formParams();
97+
console.log(formParams);
98+
ok(!formParams.is_disabled, 'Disabled field is not included');
99+
equals(formParams.not_disabled, 'not disabled', 'Not disabled field');
100+
});
101+
94102
});

dom/form_params/test/basics.micro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@
4040

4141
<input type='text' name='test[first]' value='test_first' />
4242
<input type='text' name='bla[first]' value='bla_first' />
43+
44+
<input type='text' name='is_disabled' disabled='disabled' value='disabled' />
45+
<input type='text' name='not_disabled' value='not disabled' />
4346
</form>

0 commit comments

Comments
 (0)