Twitter BootBox を次のように開いています。
bootbox.dialog("{{$steps[0]}}");
10 秒後、次のように BootBox を閉じます。
window.setTimeout(function(){
bootbox.hideAll();
}, 10000);
BootBox で閉じるまでの残り秒数を表示することはできますか?
Twitter BootBox を次のように開いています。
bootbox.dialog("{{$steps[0]}}");
10 秒後、次のように BootBox を閉じます。
window.setTimeout(function(){
bootbox.hideAll();
}, 10000);
BootBox で閉じるまでの残り秒数を表示することはできますか?
div
次のように、メッセージに を追加できます。
bootbox.dialog("Your message <div id='SecondsRemaining'>10</div>");
次に、この関数を使用して更新します。
(function(){
var remaining = 10; // Number of seconds
var obj = document.getElementById("SecondsRemaining");
var timeout = window.setInterval(function(){
remaining--;
if(remaining==0) {
// Time is up, stop the timer and hide the bootbox
window.clearInterval(timeout);
bootbox.hideAll();
return;
}
obj.innerHTML = remaining; // Update the value displayed
}, 1000); // Decrease counter every second
})();
ブートボックス 4+ では、フォーマットが変更されました。ダイアログが作成されます。
bootbox.dialog({ message: "Your message <div id='SecondsRemaining'>10</div>" });