我在动态行表中遇到了datepicker的问题。
price_date[0]
),则它可以正常工作。price_date[]
),则会产生错误无法设置未定义的属性currentDay
。datepicker
,但点击日期会显示错误。price_date[]
没有显示错误。
i = parseInt($('#counter').val());
$("#add_row").click(function(){
$('#addr'+i).html("<td align='right'>"+ (i+1) +"</td>\
<td class='col-xs-2'>\
<input type='text' name='harga_start_date[]' id='harga_start_date[]' class='datepick form-control' >\
</td>");
$('#tab_logic').append('<tr id="addr'+(i+1)+'"></tr>');
i++;
});
$("#delete_row").click(function(){
if(i> 1){
$("#addr"+(i-1)).html('');
i--;
}
});
$(document).on('focus',".datepick", function(){
$(this).datepicker({
dateFormat : 'yy-mm-dd',
changeMonth: true,
changeYear: true
});
});
&#13;
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<table class="table table-striped" id="tab_logic">
<thead>
<tr>
<td colspan="7">
<a id="add_row" class="btn btn-success btn-sm pull-left">Add Row</a><a id="delete_row" class="pull-right btn btn-danger btn-sm">Delete Row</a>
</td>
</tr>
<tr class="success">
<th class="text-center">No.</th>
<th class="text-center">Start Date</th>
</tr>
</thead>
<tbody >
<tr id='addr0' class="itemsGroup">
<td align="right">1
</td>
<input type="hidden" name="counter" id="counter" value=1>
<td class="col-xs-8">
<input type="text" name="harga_start_date[]" id="harga_start_date[]" class="datepick form-control" >
</td>
</tr>
<tr id='addr1'></tr>
</table>
&#13;
答案 0 :(得分:3)
如果我理解正确的问题,你必须改变两件事。
require 'net/imap'
def index
conn = Net::IMAP.new('imap.mail.yahoo.com', 993, ssl:true)
conn.login("email", "mypassword")
conn.select("INBOX")
conn.uid_search(['ALL']).each do |uid|
# fetches the straight up source of the email for ymail to parse
msg = conn.fetch(uid, 'RFC822').first.attr['RFC822']
mail = Mail.read_from_string msg
puts mail.subject
puts mail.text_part.body.to_s
puts mail.html_part.body.to_s
end
end
属性(您已经知道这一点)。id
中初始化插件,而插件本身会关注它。 所以解决方案是分别初始化任何输入(第一个和下一个)(当页面被加载时以及每次添加一行之后。
focus
&#13;
i = parseInt($('#counter').val());
$("#add_row").click(function () {
var addr = $('#addr' + i).html("<td align='right'>" + (i + 1) + "</td>\
<td class='col-xs-2'>\
<input type='text' name='harga_start_date[]' class='datepick form-control' >\
</td>");
$('#tab_logic').append('<tr id="addr' + (i + 1) + '"></tr>');
attachDatepicker(addr.find('input'));
i++;
});
$("#delete_row").click(function () {
if (i > 1) {
$("#addr" + (i - 1)).html('');
i--;
}
});
function attachDatepicker(input) {
input.datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true
});
}
attachDatepicker($('input'));
&#13;