English 中文(简体)
有关对象元素的jQuery 事件是否有效?
原标题:Do jQuery events on object elements work?

我无法将jQuery 事件收听器成功附加到类型 的元素上, 并让它接收该事件引发的任何事件 。

因此:

<object></object>

使用 JavaScript :

$( object ).on( foo , function(evt, data){ alert(data) });
$( object ).trigger( foo ,  object-on-object );

如果我在 $( body) (body) 上有完全相同的代码, 那么它就很好。 另外, 如果我在 lt;body> $( objects) > (trigger) 上听到事件, 那么我就会得到这个事件 。

我有一个 < a href=> "" "http://jsfiddle.net/bxnKR/1/" rel="nofollow" >jsFiddle 来证明这一点。 您可以在它看到 bar 事件没有产生输出, 但两个 foo 事件有。

最佳回答

因此,答案似乎是否定的。根据此线索 ,有些问题与约束性事件有关,或者可能与jQuery和元素有关。

解决办法似乎是让事件在别处泡沫化。 $( document) 似乎是一个有效的选择,所以你可以做一些事情,比如:

$(document).on( foo ,  object , {data: data}, handler);

$( object ).trigger( foo );

对于我想要的东西来说,这是一种错误的方式(我想告诉消费者听插件元素上的事件),但效果很好。在代码、文档中无法修正的东西。

问题回答

暂无回答




相关问题
Mysql trigger/events vs Cronjob

I have an auction website which let my users place an unlimited amount of autobiddings. To monitor these autobiddings something has to check the database every second. My question is if it is ...

Can an event be used as an event listener?

I m trying to expose some events from a private object which is contained inside the object I am creating and it looks like the compiler is happy with this: private WindowUpdateServer ...

鸡奸

由于将javascript DOM方法放在第html页底部(在<有人>之后)远比利用“j Query”准备活动要快得多,因此我们不得不这样做:

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

jQuery bind on ajax load() event

I have a page which displays multiple blocks with results details. Inside each block I have some <a> tags with thickbox jQuery plugin attached: class="thickbox" Here is an example of one kind ...

HTML text input event

I have a form, and want to disable/enable its submit button depending on whether the form s input text fields are empty or have had text entered into them. I think this means having an event handler ...

IE doesn t run Javascript when you click back button

I ve built a shop with tons of JS running. One of the pieces of the cart, is a zip code field which is required to calculate shipping cost. This works fine going through the cart. Now clicking ...

热门标签