这是交易:bootstrap datepicker在第一次加载页面时就像一个魅力。但是当我执行任何事件(按钮单击,显示模态,隐藏模态,更改GridView中的分页等)时,datepicker停止工作。无论页面中出现什么情况,我如何维护日期选择器设置?
以下是重要的代码部分:
<div class="row">
<div class="col-sm-2 col-sm-offset-3" style="margin-bottom: 10px; margin-right:30px">
<label>Data início:</label>
<div class='input-group date' id='dataInicioPicker' style="width:0;">
<asp:TextBox runat="server" ID="txbDataInicio" CssClass="form-control text-datas"></asp:TextBox>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
</div>
<div class="col-sm-2" style="margin-bottom: 10px;">
<label>Data fim:</label>
<div class='input-group date' id='dataFimPicker' style="width:0">
<asp:TextBox runat="server" ID="txbDataFim" CssClass="form-control text-datas"></asp:TextBox>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#dataInicioPicker').datepicker({
format: 'dd/mm/yyyy',
language: "pt-BR",
});
$('#dataFimPicker').datepicker({
format: 'dd/mm/yyyy',
language: "pt-BR",
});
});
</script>
重要:
ScriptManager.RegisterStartupScript()
重新定义文本框中的设置,则datepicker将继续按预期工作(但我不想对每个人都这样做 - 方法every-freakin-time)答案 0 :(得分:1)
所以根据这个链接:
<script type="text/javascript">
$(document).ready(function() {
//jquery code
});
var parameter = Sys.WebForms.PageRequestManager.getInstance();
parameter.add_endRequest(function() {
//jquery code again for working after postback
});
</script>
干杯,