2016-03-04 60 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