Changeset 4587 for trunk/plugins/validate/demo/dynamic-totals.html
- Timestamp:
- 02/01/08 23:30:06 (1 year ago)
- Files:
-
- 1 modified
-
trunk/plugins/validate/demo/dynamic-totals.html (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/validate/demo/dynamic-totals.html
r4565 r4587 7 7 8 8 <link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" /> 9 9 10 <script src="../lib/jquery.js" type="text/javascript"></script> 10 <script type="text/javascript" src="../lib/jquery.delegate.js"></script>11 11 <script src="../jquery.validate.js" type="text/javascript"></script> 12 12 … … 21 21 22 22 $().ready(function() { 23 var validator =$("#orderform").validate({23 $("#orderform").validate({ 24 24 errorPlacement: function(error, element) { 25 25 error.appendTo( element.parent().parent().next().find("td." + element.parent().attr("class") + "-error") ); … … 27 27 }); 28 28 29 // TODO improve templating code29 var template = jQuery.format($("#template").val()); 30 30 function addRow() { 31 // add another input with a generated name and remove the id to avoid duplicates 32 var items = $("#items").clone().attr("id", "").attr("name", "item-type-" + i).show(); 33 $("#template, #template+").clone().attr("id", "").show() 34 .find("label").text((i + 1) + ". Item").end() 35 .find(".type").append( items ).end() 36 .find("input.quantity").attr("name", "item-quantity-" + i).end() 37 .appendTo("#orderitems tbody"); 38 i++; 31 $(template(i++)).appendTo("#orderitems tbody"); 39 32 } 40 33 41 var i = 0;34 var i = 1; 42 35 // start with one row 43 36 addRow(); … … 85 78 <div id="main"> 86 79 87 <t able style="display:none">88 <tr id="template">80 <textarea style="display:none" id="template"> 81 <tr> 89 82 <td> 90 <label> </label>83 <label>{0}. Item</label> 91 84 </td> 92 <td class='type'></td> 85 <td class='type'> 86 <select class="required" name="item-type-{0}"> 87 <option value="">Select...</option> 88 <option value="0">Learning jQuery</option> 89 <option value="1">jQuery Reference Guide</option> 90 <option value="2">jQuery Cookbook</option> 91 <option vlaue="3">jQuery In Action</option> 92 <option value="4">jQuery For Designers</option> 93 </select> 94 </td> 93 95 <td class='quantity'> 94 <input size='4' class="quantity required" min="1" />96 <input size='4' class="quantity required" min="1" name="item-quantity-{0}" /> 95 97 </td> 96 98 </tr> … … 101 103 <td class='quantity-error'> </td> 102 104 </tr> 103 </table> 104 105 <select id="items" class="required" style="display:none"> 106 <option value="">Select...</option> 107 <option value="0">Learning jQuery</option> 108 <option value="1">jQuery Reference Guide</option> 109 <option value="2">jQuery Cookbook</option> 110 <option vlaue="3">jQuery In Action</option> 111 <option value="4">jQuery For Designers</option> 112 </select> 105 </textarea> 113 106 114 107 <form id="orderform" class="cmxform" method="get" action="foo.html">
