从标题本身。是的,您如何在页面重定向后保持 bulma 的活力?目前,我用 bulma 烤面包保存数据的代码工作正常。但我想要实现的是在重定向后保持吐司。
这是我用于保存数据的ajax代码:
$.ajax({
headers:{'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
url: "{{ route('payNow') }}",
method: "POST",
data:{payNow: "TRUE"},
dataType: "json",
success:function(data)
{
if(data.success.length > 0){
// getDtls();
window.location = "//mydomain/reseller/transaction_history";
bulmaToast.toast({ message: data.success[0],
dismissible: true,
duration: 3000,
pauseOnHover: true,
animate: { in: "fadeIn", out: "fadeOut" },
type: "is-success" });
}else{
bulmaToast.toast({ message: data.error[0],
dismissible: true,
duration: 3000,
pauseOnHover: true,
animate: { in: "fadeIn", out: "fadeOut" },
type: "is-danger" });
}
},
error: function(xhr, ajaxOptions, thrownError){
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
正如你所看到的,我在window.location
之前先编码bulmaToast
,希望网络首先重定向并显示toast
效果。
toast显示成功,但是由于重定向导致toast显示太快
它无法正确显示 toast,因为代码已经开始过渡到下一页。如果您希望 Toast 显示在下一页上,则需要在转换之前将Toast 闪存到会话中,或者使用对 window.location 的 setTimeout 回调在当前页面上显示 Toast。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句