定義:javascript
var waitUnitil=function (untillCallBack, nextStepCallBack, count) { if (count == null) { count = 0; } var timer = setInterval(function (ucb, ncb, c) { var checkResult = ucb(); if (c == 100 || checkResult) { clearInterval(timer); ncb(); interval = null; return; } console.log((c++) + "," + checkResult); }, 10, untillCallBack, nextStepCallBack, count); }
調用:java
waitUnitil( function () { return walletContactInfoCreator.getEle$("#AddressInfo_City").find("option").length > 1; },//終止條件 function () { walletContactInfoCreator.getEle$("#AddressInfo_City").val(walletContactInfoCreator.entityV.AddressInfo.City).change(); }//下一步 )