以下是github文档:https://github.com/msurguy/ladda-bootstrap
我正在努力使我的代码工作,但出于某种原因,ladda不会停止旋转(按钮再也不会被启用),即使我在AJAX调用之后放置了"Ladda.stopAll();“。这是我的密码:
<button type="button" class="btn btn-lg btn-success ladda-button" data-style="expand-left" id="genPDF"><span class="ladda-label">Generate PDF</span></button>
<script>
Ladda.bind('button[id=genPDF]');
$('#genPDF').click(function () {
//Another approach I tried
//Ladda.bind(this);
var str = "tmName=" + $("#tmName").val() +
"&headingText=" + $("#headingText").val();
$.ajax({
url: "testing.php",
data: str,
cache: false,
success: function (data) {
//None of this code matters, it all works fine
console.log(data);
var container = document.getElementById("pdfContainer");
var content = container.innerHTML;
container.innerHTML = content;
}
});
//If I placed Ladda.stopAll(); here, the ladda wouldn't even
//START spinning upon being clicked on.
});
</script>发布于 2016-04-26 21:34:13
我相信这是你的问题
Ladda.bind('button[id=genPDF]');文档:
//在单击时自动触发加载动画 Ladda.bind('inputtype=submit‘); //与上述相同,但在2秒后自动停止 Ladda.bind( 'inputtype=submit',{ timeout: 2000 } );
当它说“自动触发点击加载动画”时,它实际上就是这样做的。它加载它,这导致它继续运行,因为你从来没有让它停止。
发布于 2018-08-08 10:03:32
用这个就行了
$('#yourladda_btn').click(function(){
var l = Ladda.create(this);
l.start();
$.ajax({
url: 'test.php',
type: "post",
data: {"yourdata":"test"},
success: function(){
}
}).always(
function() {
l.stop();
}
);
});https://stackoverflow.com/questions/36876094
复制相似问题