【问题标题】:Bootstrap3 Datetimepicker issues: missing icon, how to use Date() function?Bootstrap3 Datetimepicker 问题:缺少图标,如何使用 Date() 函数?
【发布时间】:2015-07-15 10:36:49
【问题描述】:

我在这个网站上使用为 Meteor 打包的 Bootstrap3 Datetimepicker:

https://github.com/tsega/meteor-bootstrap3-datetimepicker

我有两个问题。

1) 点击打开日历的按钮上没有日历图标。

2) date() 函数失败并出现错误:“模板助手中的异常:TypeError: $(...).datetimepicker(...).date is not a function”。

这是我通过命令行包含的内容:

meteor add jquery
meteor add mrt:moment
meteor add twbs:bootstrap 
meteor add tsega:bootstrap3-datetimepicker

可能这些不是正确的软件包,但它们确实让它基本上可以工作......

我已经按照作者页面上的示例进行了操作。这是我的 JavaScript:

if (Meteor.isClient) {
  Template.say_when.onRendered(function() {
    this.$('.datetimepicker').datetimepicker({
    }).on('dp.change', function(e){
      Session.set("selected", e.date.format());
    });
  });

  Template.say_when.helpers({
    // Works
    show_date: function(){
      return Session.get("selected");
    },
    // Fails
    test: function(){
      var date = $('.datetimepicker').datetimepicker().date();
      console.log("Date from picker: " + date);
    }
  });
}

这是我的 HTML:

<head>
  <title>datetimepicker</title>
</head>

<body>
  <h1>Bootstrap3 Datetimepicker in Meteor</h1>

  {{> say_when}}
</body>

<template name="say_when">
  <div class="input-group datetimepicker">
    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
    <input class="set-due-date form-control" type="text"/>
  </div>

  <p>{{show_date}}</p>
  <p>{{test}}</p>
</template>

1) 为了获得日历图标,我还需要添加其他内容吗?

2) 如何使 date() 函数工作?

【问题讨论】:

    标签: twitter-bootstrap meteor datetimepicker


    【解决方案1】:

    看看我做过的同一个项目。

    很快就会给出答案

    https://github.com/kokaqux/posttracker

    【讨论】:

    • 我的问题是如何使用 date() 方法?在您的项目中,我认为您使用 jQuery 获得了输入的当前值,使用以下代码: time: $('#datetimepicker').val() 我想使用组件的方法而不是依赖于知道 HTML 是如何的结构化,并且我希望能够使用文档中描述的其他方法。我可能很笨,但我就是不知道如何使任何方法起作用!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-09
    相关资源
    最近更新 更多