jQuery和原型事件 [英] jQuery and Prototype events

查看:106
本文介绍了jQuery和原型事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在加载事件触发的原型代码:

  Event.observe($(imageEl) 'load',this.someFunction.bind(this)); 

当我使用jQuery代码创建Real事件,如

  jQuery(... imageEl selector ...)。attr(src,filename); 

它触发了Prototype代码(someFunction)。



接下来我尝试使用jQuery触发器来触发原型代码:

  jQuery(... imageEl selector ...)。trigger('load'); 

但现在,没有任何事情发生,即这行不会触发原型代码。



任何想法如何从jQuery触发Prototype事件?



谢谢,
Sty

解决方案

您应该直接传递所需参数或触发本机DOM事件 p>

注意:原型的fire和jquery的触发器创建自定义事件,而不是本机。



阅读以下有关如何触发的答案本地事件:




I have a Prototype code that is triggered upon 'load' event:

  Event.observe($(imageEl), 'load', this.someFunction.bind(this));

When I create 'Real' event using jQuery code like

  jQuery(...imageEl selector...).attr("src", filename);

it fires the Prototype code (someFunction). Good!

Next I try to fire the Prototype code using jQuery trigger:

  jQuery(...imageEl selector...).trigger('load');

But now, nothing happen i.e. this line doesn't fire the Prototype code.

Any idea how to trigger a Prototype event from jQuery?

Thanks, Sty

解决方案

You should call your handler directly passing required arguments or trigger the native DOM event.

NOTE: prototype's fire and jquery's trigger create custom events, not native.

Read the following answers on how to trigger native events:

这篇关于jQuery和原型事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆