Gif加载器在订阅后不会隐藏
Gif loader does not hides out after subscribing
我正试图将SendGrid订阅小部件集成到我的网站(https://github.com/sendgrid/sendgrid-subscription-widget)。该公司提供的示例代码部分可以正常工作。当我点击注册按钮时,加载器显示并显示成功消息,但gif加载器即使在收到消息后也不会隐藏。我希望加载器停止显示一旦过程完成。我已经粘贴了js代码片段。我发现不了问题。这可能是由于我的边际js知识。
$(".sendgrid-subscription-widget").on("sent", function () {
$(this).addClass("loading")
.append("<img src='"http://i.imgur.com/6RMhx.gif'" alt='"Loading...'">");
$(this).find("input[type=submit").attr("disabled", "disabled");
$(".sendgrid-subscription-widget").on("success error", function () {
$(this).removeClass("loading")
$(this).find("img").remove();
$(this).find("input[type=submit").removeAttr("disabled");
});
});
HTML标记<div class="sendgrid-subscription-widget" data-token="1M5Z249eGJzJ34D5llN3s2KkzNImaU9gZp8ImuJSw1pmhsJvugAYeWJXhtK1aWLO" data-executed="true">
<form>
<div class="response"></div>
<label>
<span>Email</span>
<input type="email" name="email" placeholder="you@example.com" />
</label>
<input type="submit" value="submit" />
</form>
<img src="http://i.imgur.com/6RMhx.gif" alt="Loading...">
</div>
把你的Js改成这样:
$(".sendgrid-subscription-widget").on("sent", function () {
$(this).addClass("loading")
.append("<img src='"http://i.imgur.com/6RMhx.gif'" alt='"Loading...'">");
$(this).find("input[type=submit").attr("disabled", "disabled");
$(".sendgrid-subscription-widget").on("success error", function () {
$(this).removeClass("loading")
$(document).find(".loading img").remove();
$(this).find("input[type=submit").removeAttr("disabled");
});
});
好了,我解决了:这段代码现在正在工作…他的控制台帮助了我。
$(".sendgrid-subscription-widget").on("sent", function () {
$(this).addClass("loading")
.append("<img src='"http://i.imgur.com/6RMhx.gif'" alt='"Loading...'">");
$(this).find("input[type=submit]").attr("disabled", "disabled");
$(".sendgrid-subscription-widget").on("success error", function () {
$(this).removeClass("loading")
$(this).find("img").remove();
$(this).find("input[type=submit]").removeAttr("disabled");
});
});
相关文章:
- Bootstrap在页面加载缓慢时会立即显示隐藏的模式对话框
- 在第一页加载时隐藏字段,而不是在php发布之后
- 隐藏元素直到加载完成(ng斗篷不是我需要的)
- 谷歌地图加载后隐藏加载图像
- AngularJS - 显示/隐藏加载器
- 将调整大小的图像作为下载提供后,隐藏加载的 GIF
- 根据条件从代码隐藏加载html页面
- ajax在没有更多数据的情况下隐藏加载更多按钮
- 在找不到.HTML文件时隐藏加载栏
- 检测javascript完成以显示/隐藏加载图标
- 函数完成后隐藏加载覆盖
- 使用jQuery下载大文件;iFrame -需要一个文件准备事件,所以我可以隐藏加载gif
- 隐藏加载数据,一旦页面已加载
- 显示被点击的元素的隐藏加载器
- Javascript / Jquery:显示和隐藏加载屏幕消息
- 自动隐藏“加载更多”选项卡内的按钮
- Chrome不显示和隐藏加载程序
- 显示和隐藏加载gif的最佳实践
- 如何在d3中隐藏加载图后的加载图像
- 在ajax回调后隐藏加载gif