gpt4 book ai didi

javascript - 如何停止现有的微调器

转载 作者:行者123 更新时间:2023-11-30 12:25:51 25 4
gpt4 key购买 nike

我有以下 Ajax 请求,它位于从服务请求地址的局部 View 中,可能需要几秒钟来填充表格:

@using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = "updatearea", OnBegin = "ShowLoading", OnComplete = "HideLoading" }))
{
<div id="updatearea" class="form-group">

<div style="width:300px; display:block; float:left;">
@Html.TextBox("PostCode", null, new { @class = "form-control" })
</div>

<div id="NewAddressLine">

<input id="btnLookupPostcode" type="submit" value="Lookup Postcode" class="btn btn-default" />
</div>
</div>

<div id="spinner"></div>
}

这个 JavaScript 成功启动了加载微调器,但在部分 View 完全呈现后不会停止它:

function ShowLoading() {
var opts = {
lines: 13, // The number of lines to draw
length: 20, // The length of each line
width: 10, // The line thickness
radius: 30, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 0, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color: '#000', // #rgb or #rrggbb or array of colors
speed: 1, // Rounds per second
trail: 60, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: '50%', // Top position relative to parent
left: '50%' // Left position relative to parent
};
var target = document.getElementById('spinner');
var spinner = new Spinner(opts).spin(target);
}

function HideLoading() {
var spinner = $('.spinner');
spinner.stop();
}

请让它停止!

最佳答案

最初作为评论发布,有点激进的解决方案,但这将完全阻止它:

spinner.remove()

清除所有引用和附加事件...

关于javascript - 如何停止现有的微调器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29418204/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com