我在我的网站测试中使用了Syn.js,但是当我使用Syn.click然后尝试检查事件之后发生的事情(如标题更改或不起作用)时我会遇到问题。
就像onClick事件在开始检查之后发生的事情之前没有结束。
onClick函数是我看不到的东西所以我不能放置自定义事件以确保它已经结束所以我需要一种不同的方法来做到这一点。
我需要一种方法来确保事件结束以继续到代码中的下一行而不更改事件本身。
我真的需要一个想法,因为我不知道如何继续。
它可以是JavaScript,jQuery,等等......
//syn.js ---- this is from the syn.js (from the internet)
"_click": function (options, element, callback, force) {
Syn.helpers.addOffset(options, element);
Syn.trigger("mousedown", options, element);
//timeout is b/c IE is stupid and won't call focus handlers
schedule(function () {
Syn.trigger("mouseup", options, element);
if (!Syn.support.mouseDownUpClicks || force) {
Syn.trigger("click", options, element);
callback(true);
} else {
//we still have to run the default (presumably)
Syn.create.click.setup('click', options, element);
Syn.defaults.click.call(element);
//must give time for callback
schedule(function () {
callback(true);
}, 1);
}
}, 1);
}
// eventually it calls element.dispatchEvent(event); in syn.js
并且用户使用我的应用程序(jasmin + syn + etc ...)
// user code (sort off) : (doesnt work)
Syn.click({}, button);
expect(title).not.BeNull; // -------- here is the probleme the title need to be something but its not.
// user code (sort off) : (work)
Syn.click({}, button);
setTimeout(function() {
expect(title).not.BeNull;},1000); // ----------- I need to do this but not in here ( the user cant write this it looks bad----
我唯一可以改变的是syn.js或介于两者之间的东西因为我不希望用户在他不需要的代码中写东西。
如果用户在每个Syn。***之后写一个setTimeout,它看起来真的很难看,我不希望这样。
我也在syn.js中尝试过setTimeout,但它仍然不起作用。
答案 0 :(得分:0)
好的,我找到了答案,我更改了用户给我的代码,所以在每次同步操作后,所有内容都将成为回调,所以只有当它完成检查后才会开始