gpt4 book ai didi

twitter-bootstrap - 使用带 meteor 的日期选择器

转载 作者:行者123 更新时间:2023-12-04 07:44:25 25 4
gpt4 key购买 nike

为了在我的 meteor 应用程序中使用日期选择器,我已经尝试了一天。这里有几个问题,但似乎都没有提供完整的答案。我终于按照这个安装了一个而没有引起错误-

OK, I got this working manually using bootstrap-datepicker.js and datepicker.css from http://www.eyecon.ro/bootstrap-datepicker/ and dropping these files into the client folder. Used the markup as mentioned in that page along with the following template helper:

Template.templatename.rendered = function() {
$('#datepicker').datepicker();
}

无论我在模板中输入什么信息,我都无法让它工作,所以我尝试了模板助手的这个答案-

    Template.datepicker.events ({           
'focus #datepicker': function () {
$('#datepicker').datepicker({
format: 'M dd, yyyy',
autoclose: true
})
console.log('#datepicker has focus');
}
});

仍然只是一个空白的输入字段。这是我当前的 html 模板-

<template name="datepicker">
<div class="input-append date" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<input id="datepicker" class="span2" size="16" type="text" value="12-02-2012">
<span class="add-on"><i class="icon-th"></i></span>
</div>

</template>

我怀疑我唯一的问题是理解日期选择器返回模板的内容。

最佳答案

问题似乎是您从不告诉日期选择器“显示”。您将初始化代码放在应该告诉它显示的“焦点”事件中。例如,尝试:

Template.datepicker.rendered = function() {
// initialize datepicker
$('#datepicker').datepicker({
format: 'm, dd, yyyy'
});
};

Template.datepicker.events ({
'focus #datepicker': function () {
// show datepicker
$('#datepicker').datepicker('show');
console.log('#datepicker has focus');
}
});

或者,这个 datetimepicker package对我来说效果很好。

关于twitter-bootstrap - 使用带 meteor 的日期选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26305575/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com