2016-01-20 31 views

回答

3

我发现了一个清晰的解决方案:

  1. 设置提交按钮属性禁用
  2. 使用onReady回调braintree.setup( )启用提交按钮。
1

如果您不包含插入Braintree UI的任何其他子元素,则可以使用下面的脚本检查是否存在子元素(braintree设置应该添加),还将检查对象是否为braintree对象在window上定义。注意:childElementCount要求polyfill支持IE8。

HTML:

<div id="braintreeCompHere"></div> 

脚本:

checkForBraintree('braintreeCompHere'); 

function checkForBraintree(btContainer) { 
    var elBool = document.getElementById(btContainer).childElementCount > 0, 
     btBool = typeof window.braintree !== 'undefined'; 

    return elBool && btBool; 
} 
相关问题