2013-10-08 66 views
0

我想使用这个脚本我的登录表单提交按钮,但它不工作之前使用的JavaScript ladda ...发布形式

脚本:http://lab.hakim.se/ladda/

基本上,我wan't能够在点击并提交之前显示加载指示器。你们有没有人知道如何做到这一点?

+1

你能告诉我们更多的细节?可能console.log错误,警告甚至jsfiddle – GuramK

回答

0

你需要赶上submiting形式(IM戈纳使用CoffeeScript的,但你可以把它转换为它的jQuery的JavaScript的等价物)

$("myform").on "submit" , (e)-> 
    e.preventDefault() 
    data = $("myform").serialize() 
    ladda = Ladda.create($(@).find("submit-button")[0]) 
    // in the version i use i have to use [0] because the ladda does not accept a jquery object, it needs a dom object 
    ladda.start() //this starts the animation 
    $.post("path/for/post", 
    data: data 
).always -> 
    ladda.stop() //this stops the animation on any case fail or success