The bug happens due to the fact, that jQuery "cleans up the event in
case it is reused" in his trigger method (e.target = elem). If a
change is detected the current implementation calls trigger with the
element as the elem-argument for trigger. (with live: in most cases
the document/with bind: in most cases the select-element itself)

This means that the change-event is actually triggered on the
document, but e.target references also the document-object, so that
the closest-method can´t find a matching element and won´t call your
event-handler.

This also explains why the strange behavior occurs if you additionally
bind a change event directly to the select-element. The change is
detected and the trigger function is invoked with the select-element
as the elem-argument, so that it can be handled properly by live,
too.

Additionally it explains, why this bug could pass the testsuite.
change is testet here with both bind and live in one page at one time.
This is really annoying, but it´s extremly hard to build a good
testcase for the change-event and noone thought about such an
interference.

The code explained above will fix this issue.

On 18 Jan., 11:51, Mattias Hallström <matt...@problem.se> wrote:
> We have the same problem, but found out that it works if we chain bind
> and live like this:
>
> this.bind("change", function(e){
>                 // Do nothing
>         }).live("change", function(e){
>
> });
>
> Not sure why though?!
>
> //Mattias
> On 16 Jan, 14:34, mape <katapultstolpil...@gmail.com> wrote:
>
> > The example works fine in Firefox 3.6, Safari 4.0.4 and Chrome
> > 4.0.295.0 dev.
>
> > Doesn't seem to work in IE8 (native) and IE6, IE7 (though IEtester).
>
> >http://mape.me/jquery/select-live-ie/
-- 
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to