【问题标题】:Cannot get jQuery call right for eternicode Bootstrap datepicker无法为 eternicode Bootstrap datepicker 正确调用 jQuery
【发布时间】:2015-11-17 08:59:23
【问题描述】:

我一直在尝试 eternicode/bootstrap-datepicker (https://github.com/eternicode/bootstrap-datepicker)。我试用了沙盒 (http://eternicode.github.io/bootstrap-datepicker/),只是想使用突出显示“今天”的“组件”版本。

我有两个我认为是同一件事的问题:1)只有当您单击 input 空间时,单击字形图标时才会显示日期,以及 2)我无法获得“今天”突出工作。

我 99% 确定这是错误的 jQuery 调用。我已经尝试了各种方法让它按照 Sandbox 等启动,但我的 JS/jQuery 不能胜任这项工作。

(时间选择器 (https://github.com/jdewit/bootstrap-timepicker) 目前可以在没有 jQuery 启动脚本的情况下正常工作)。

部分问题在于,当我从 GitHub 下载 zip 文件时,有两个 .less 文件(我认为)都是 Bootstrap2。

感谢您的帮助。

<div class="form-group col-sm-3 colFlushL">
    <label class="control-label" for="zaq-timeSimple">Time</label>
    <div class="input-group bootstrap-timepicker timepicker colFlush ">
        <input id="timepicker1" type="text" name="arse"
               class="form-control">
        <span class="input-group-addon"><i
                class="glyphicon glyphicon-time"></i></span>
    </div>
</div>

<div class="form-group col-sm-3 colFlush"  id="zaq-startDate">
    <label class="control-label" for="zaq-startDate">Start Date</label>
    <div class="input-group colFlush">
        <input type="text" class="form-control date" name="datepicker"
               data-provide="datepicker">
        <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
    </div>
</div>

这是我 jQuery 尝试的最新版本,我 95% 肯定这很可怕。

<script>
$('.datepicker.date').datepicker.(
    {
        todayHighlight: true
    }
)
</script>

NB 根据 phpStorm,日期不是我认为包含 .less 文件的任何地方定义的类

PS 我应该说页面上的两个日期选择器 100% 通过表单传递日期值。

【问题讨论】:

  • 没有两个类 .datepicker.date 的元素。它正在寻找具有class="datepicker date" 的元素
  • 试过&lt;div class="input-group colFlush datepicker date"&gt;,但没有这样做。 $('.datepicker.date').datepicker.( 中的最后一个“日期选择器”是什么意思?
  • 你能在jsfiddle.net准备一个demo吗?
  • 好的,谢谢大家。早上会试试(我觉得 jsfiddle 有点吓人,不太确定你想要什么)。我尝试了一个简单的 id 选择器$('#zaq').datepicker.(,但没有任何乐趣。早上吃 X 光片和钡餐,所以试着去睡觉。
  • 好吧,我不知道我在做什么,但jsfiddle.net/stevenhomer/gw6a5sn2 也有真实页面,这可能更容易moviemaui.com/sane30/beta30/createTransmissionSimple.php。但我的困惑来自 a) 不知道要使用 github.com/eternicode/bootstrap-datepicker 的哪些部分和 b) 对触发 jQ 的困惑。我是一个基本的应用程序用户——我使用简单的 js 文件、一点点 CSS,然后复制一点点 JS 来让它工作。这个应用程序似乎维护得很好,但它需要 Bower 或 NPM 或 Grunt 等,这对于我正在构建的简单项目来说是我头疼的。

标签: javascript jquery twitter-bootstrap datepicker


【解决方案1】:

好吧,这是一个错字(或者更准确地说是新手缺乏对 jQuery 的理解!!)

$('.datepicker.date').datepicker.(

应该是

$('.datepicker.date').datepicker(

IE 我卡在一个额外的时期。 (这至少花了我两个小时!天哪!)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-20
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多