【问题标题】:Jasmine jquery test event handler onJasmine jquery 测试事件处理程序
【发布时间】:2016-05-10 13:37:42
【问题描述】:

在这种情况下如何触发事件:

要测试的代码:

   $("body").on("touchstart", "[title]", function (event) {}

我正在尝试以这种方式进行测试,但它不起作用。

event = $.Event("touchstart", {target: "test"});
$("body, title").trigger(event);

有人知道怎么测试吗?

【问题讨论】:

    标签: jquery unit-testing jasmine


    【解决方案1】:

    问题出在 $.Event 上。 $('[title]').first().trigger('touchstart', {target: "test"}); 工作正常

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-23
      • 1970-01-01
      相关资源
      最近更新 更多