mirror of
https://github.com/sstent/node.git
synced 2026-01-25 14:42:00 +00:00
changeing templating logic
This commit is contained in:
@@ -19,10 +19,10 @@
|
|||||||
ul#employees
|
ul#employees
|
||||||
|
|
||||||
form#myForm
|
form#myForm
|
||||||
div.Name#input1(style='display: none')
|
div.Template_Name(style='display: none')
|
||||||
input(type='text', id='employee_name', value='name')
|
input(type='text', id='employee_name', value='name')
|
||||||
input(type='text', id='employee_salary', value='salary')
|
input(type='text', id='employee_salary', value='salary')
|
||||||
div.Exercise#input1(style='display: none')
|
div.Template_Exercise(style='display: none')
|
||||||
input(type='text', id='employee_name', value='Exercise')
|
input(type='text', id='employee_name', value='Exercise')
|
||||||
input(type='text', id='employee_salary', value='Sets')
|
input(type='text', id='employee_salary', value='Sets')
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,13 @@ html
|
|||||||
var newNum = new Number(num + 1); // the numeric ID of the new input field being added
|
var newNum = new Number(num + 1); // the numeric ID of the new input field being added
|
||||||
|
|
||||||
// create the new element via clone(), and manipulate it's ID using newNum value
|
// create the new element via clone(), and manipulate it's ID using newNum value
|
||||||
var newElem = $("."+classname+"#input" + num).clone().attr('id', 'input' + newNum);
|
var newElem = $(".Template_"+classname).clone().attr('id', classname + newNum);
|
||||||
|
|
||||||
newElem.children(':first').attr('id', 'name' + newNum).attr('name', 'name' + newNum);
|
//is this line needed?
|
||||||
|
//newElem.children(':first').attr('id', 'name' + newNum).attr('name', 'name' + newNum);
|
||||||
|
|
||||||
// manipulate the name/id values of the input inside the new element
|
// manipulate the name/id values of the input inside the new element
|
||||||
newElem.children(':first').attr('id', 'name' + newNum).attr('name', 'name' + newNum);
|
newElem.children(':first').attr('id', classname + newNum).attr('name', 'name' + newNum);
|
||||||
|
|
||||||
// insert the new element after the last "duplicatable" input field
|
// insert the new element after the last "duplicatable" input field
|
||||||
$("."+classname+"#input" + num).after(newElem);
|
$("."+classname+"#input" + num).after(newElem);
|
||||||
@@ -40,7 +41,8 @@ html
|
|||||||
|
|
||||||
// business rule: you can only add 5 names
|
// business rule: you can only add 5 names
|
||||||
if (newNum == 12)
|
if (newNum == 12)
|
||||||
$('#btnAdd').prop('disabled',true);
|
$('#btnAdd').
|
||||||
|
prop('disabled',true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btnDel').click(function() {
|
$('.btnDel').click(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user