手动触发datepicker onselect事件 [英] Fire the datepicker onselect event manually
本文介绍了手动触发datepicker onselect事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< script>
$(#datepicker).datepicker
(
{
altField:'#sheet',
onSelect:function load(){
$ (document).ready(function(){
$ .ajax({
type:'POST',
url:'test.php',
data:{sheetid: $('#sheet')。val()},
success:function(data)
{
$(#content)。html(data);
}
});
});
},
firstDay:1});
< / script>
解决方案
您可以触发
代码:
$(document).ready(function(){
$(#datepicker)。datepicker({
altField:'#sheet',
onSelect:function(date){
alert(date);
},
firstDay:1
});
$('#datepicker' ).datepicker(setDate,new Date(2013,09,22));
$('。ui-datepicker-current-day')。click(); //表示当前选定的日子
});
演示: http://jsfiddle.net/IrvinDominin/DynuW/
Can anyone tell me how do you trigger the onselect event of datepicker? My code is working well (pulling some data from a database based on the value of datepickers altfield) but when the page loads it doesn't trigger the onselect event on the current date and it doesn't display anything; so I would like to do that manually.
<script>
$( "#datepicker" ).datepicker
(
{
altField: '#sheet',
onSelect: function load() {
$(document).ready(function() {
$.ajax({
type: 'POST',
url: 'test.php',
data: {sheetid: $('#sheet').val()},
success: function(data)
{
$("#content").html(data);
}
});
});
},
firstDay: 1});
</script>
解决方案
You can trigger a click
on the datepicker right after the set of the date.
Code:
$(document).ready(function () {
$("#datepicker").datepicker({
altField: '#sheet',
onSelect: function(date) {
alert(date);
},
firstDay: 1
});
$('#datepicker').datepicker("setDate", new Date(2013,09,22) );
$('.ui-datepicker-current-day').click(); // rapresent the current selected day
});
Demo: http://jsfiddle.net/IrvinDominin/DynuW/
这篇关于手动触发datepicker onselect事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文