时间戳点击图标

时间:2012-08-31 09:31:40

标签: javascript twitter-bootstrap

我已经包含了timepicker,我可以选择选择点击时间。

//= require bootstrap-timepicker 

$('.timepicker-default').each(function(i) {

  //alert($(this).val());
  $(this).timepicker(
  {
    defaultTime:  $(this).val()
  });

});

现在,如果我添加twitter-bootstrap图标'icon-time',我如何获得选择点击时间的选项? 我用过这个:

 <div class="input-append bootstrap-timepicker-component">
  <input type="text" class="timepicker-default" name="planned_start_time" value="<%= @planned_start_time.nil? ? (Time.now).strftime('%I:%M%p') : @planned_start_time%>"> 
    <span class="add-on">
      <i class="icon-time"></i>
    </span>
</div>

但我的图标正在外面,我无法选择点击图标的时间。同样的事情在http://jdewit.github.com/bootstrap-timepicker/中使用。但我们可以选择时间。

1 个答案:

答案 0 :(得分:2)

我是该组件的作者。标记发生了一些变化。默认功能将满足您的需求。 // JS

$('.timepicker-default').timepicker();

// HTML

<div class="input-append bootstrap-timepicker">
    <input type="text" class="timepicker-default" name="planned_start_time" value="<%= @planned_start_time.nil? ? (Time.now).strftime('%I:%M%p') : @planned_start_time%>"> 
    <span class="add-on">
        <i class="icon-time"></i>
    </span>
</div>