I have a problem. I have a dynamic form that can generate a rows of textfields and these textfields are should be datepicker. These textfields have same classes but only the first one has a datepicker. The rest can't generate a datepicker. But when I checked their classes they have the class of datepicker.
Here's my simple code:
function addNewRowCheck() {
check_html = '<tbody id="check-row' + check_row + '">';
check_html += '<tr style="background-color: #FDCACB">';
check_html += '<td class="txt-center"><input type="hidden" name="check[' + check_row + '][order_no]" value="' + check_row + '" /></td>';
check_html += '<td>';
check_html += '<select>';
check_html += $select_account_type;
check_html += '</select>';
check_html +- '</td>';
check_html += '<td><input type="text" class="txt-center chkdate" name="check[' + check_row + '][curr]" /></td>';
check_html += '<td><input type="text" class="txt-right" name="check[' + check_row + '][rate]" /></td>';
check_html += '<td><input type="text" class="txt-right" name="check[' + check_row + '][amount]" /></td>';
check_html += '<td><input type="text" class="txt-right" name="check[' + check_row + '][check_number]" /></td>';
check_html += '<td><input type="text" class="txt-right chkdate" name="check[' + check_row + '][check_date]" /></td>';
check_html += '<td><input type="text" class="txt-right" name="check[' + check_row + '][bank_name]" /></td>';
check_html += '<td class="center"><img id="remove_btn" src="<?php echo $button_remove; ?>" onclick="$(\'#check-row' + check_row + '\').remove()" style="display: inline;" /></td>';
check_html += '<tr>';
check_html += '</tbody>';
$('#check-content tfoot').before(check_html);
check_row++;
}
....
$('.chkdate').each(function() {
$(this).datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true
});
});
var $new = $(check_html).insertBefore('#check-content tfoot'); $new.find('.chkdate').datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true });