2013-12-17 56 views
0

新的咖啡腳本,我不知道是什麼原因造成的。錯誤:解析第28行的錯誤:意外的'TERMINATOR'

$ -> 
    $('.subscription').hover (event) -> 
     $(this).toggleClass("hover") 


jQuery -> 
    Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content')) 
    payment.setupForm() 

payment = 
    setupForm: -> 
    $('#new_subscription').submit -> 
     $('input[type=submit]').attr('disabled', true) 
     payment.processCard() 
     false 

    processCard: -> 
    card = 
     number: $('#card_number').val() 
     cvc: $('#card_code').val() 
     expMonth: $('#card_month').val() 
     expYear: $('#card_year').val() 
     Stripe.createToken(card, payment.handleStripeResponse) 

    handleStripeResponse: (status, response) -> 
    if status == 200 
     alert(response.id) 
    else 
     alert(response.error.message) 

回答

1

錯誤原因是由此行:Stripe.createToken card, payment.handleStripeResponse。它不是card對象的一部分。

我更加這一切有點咖啡ISH:

$ -> 
    $('.subscription').hover (event) -> 
    $(this).toggleClass "hover" 

jQuery -> 
    Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content')) 
    payment.setupForm() 

payment = 
    setupForm: -> 
    $('#new_subscription').submit -> 
     $('input[type=submit]').attr 'disabled', no 
     payment.processCard() 
     false 

    processCard: -> 
    card = 
     number: $('#card_number').val() 
     cvc: $('#card_code').val() 
     expMonth: $('#card_month').val() 
     expYear: $('#card_year').val() 
    Stripe.createToken card, payment.handleStripeResponse 

    handleStripeResponse: (status, response) -> 
    if status is 200 
     alert response.id 
    else 
     alert response.error.message 
1
processCard: -> 
    card = 
     number: $('#card_number').val() 
     cvc: $('#card_code').val() 
     expMonth: $('#card_month').val() 
     expYear: $('#card_year').val() 
    Stripe.createToken(card, payment.handleStripeResponse) # <-- wrong identation 
相關問題