Skip to content

Commit c73d5d7

Browse files
committed
Fix dynamic-totals demo by trimming whitespace from template content before passing to jQuery constructor
1 parent 5b114e1 commit c73d5d7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

demo/dynamic-totals.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
alert("submitted!");
1717
}
1818
});
19-
$.validator.messages.max = jQuery.format("Your totals mustn't exceed {0}!");
19+
$.validator.messages.max = jQuery.validator.format("Your totals mustn't exceed {0}!");
2020

2121
$.validator.addMethod("quantity", function(value, element) {
2222
return !this.optional(element) && !this.optional($(element).parent().prev().children("select")[0]);
@@ -31,18 +31,18 @@
3131
$(element).addClass(errorClass).parent().prev().children("select").addClass(errorClass);
3232
}
3333
});
34-
35-
var template = jQuery.format($("#template").val());
34+
35+
var template = jQuery.validator.format($.trim($("#template").val()));
3636
function addRow() {
3737
$(template(i++)).appendTo("#orderitems tbody");
3838
}
39-
39+
4040
var i = 1;
4141
// start with one row
4242
addRow();
4343
// add more rows on click
4444
$("#add").click(addRow);
45-
45+
4646
// check keyup on quantity inputs to update totals field
4747
$("#orderform").validateDelegate("input.quantity", "keyup", function(event) {
4848
var totals = 0;
@@ -51,7 +51,7 @@
5151
});
5252
$("#totals").attr("value", totals).valid();
5353
});
54-
54+
5555
});
5656
</script>
5757

@@ -110,12 +110,12 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-vali
110110

111111
<form id="orderform" class="cmxform" method="get" action="foo.html">
112112
<h2 id="summary"></h2>
113-
113+
114114
<fieldset>
115115
<legend>Example with custom methods and heavily customized error display</legend>
116116
<table id="orderitems">
117117
<tbody>
118-
118+
119119
</tbody>
120120
<tfoot>
121121
<tr>

0 commit comments

Comments
 (0)