2016-03-04 59 views
0

我想确保当我的计时器结束时,我得到一个表单输入消息intead。一切正常。我只需要写作功能如果陈述。这是我的代码:当计时器结束replaceWith

var inputDate = new Date($('#count').val()); 
inputDate.setDate(inputDate.getDate()); 

$(".clock").countdown(inputDate, function(event) { 
    $(this).text(event.strftime('%D dienos %Hh %Mmin %Ssek')); 
    if (inputDate.val() == 0) { 
     var statusHTML = '<p>Siūlymai nebegalimi. Aukciono laikas baigėsi.</p>'; 
     $("#placeBid").replaceWith(statusHTML); 
    } 
}); 

当我的计时器结束时,消息不出现,窗体仍然显示。如果我这样做:

if ($(".clock").val() == 0) 

随后出现的消息,但是当计时器没有结束它仍然显示该消息,而不是输入。

编辑HTML代码

 <form id="placeBid" action="/add-new-bid/{{$product->id}}" method="Post"> 

     {!! csrf_field() !!} 

     <input type="submit" id="bidSubmit" class="btn btn-success" value="Siūlyti kainą" style="float: right" /> 

     <div style="overflow: hidden; padding-right: .5em;"> 
      <input type="hidden" value="{{$product->bid_price}}" id="jsBidPrice"> 

      <input style="width: 144px;" type="number" name="bid" class="minBid form-control" min="{{$product->bid_price}}" onkeyup="this.value = minmax(this.value, 0.01, 100)" placeholder="min. suma {{$product->bid_price}} €" style="width: 100%;" /> 

     </div>​ 
     </form> 
+1

我不知道ü为什么会投下来:) – hulkatron

+0

可以显示HTML代码? – Sumanta736

+0

是的。 @ Sumanta736 – hulkatron

回答

1

从文档

Events 

这个插件将触发一个事件,只要像一些状态变化:

Update: Triggered to update the DOM 
Finish: Triggered when finished 
Stop: Triggered that paused 

要注册一个回调的使用以下event.type:

update.countdown 
finish.countdown 
stop.countdown 

请注意,所有事件都应该使用名称空间* .countdown进行注册。

使用完成事件来获得你所需要的?

btw。你有足够的inforimations这里: enter link description here

工作例如:

$('#clock').countdown('2016/03/04 13:01:00') 
.on('finish.countdown', function(event) { 
**do all your shinigamis here** 
}); 
+0

不工作。我甚至添加了这个日期:'2016/03/03 00:01:00' – hulkatron

+0

也没有错误。 – hulkatron

+0

固定。我需要。时钟不#时钟:) – hulkatron