I came up with the following code:

// Make the following events bubble in IE
jQuery.each(["submit", "change", "select"], function(i, fix) {
        var event = jQuery.event,
                special = event.special,
                handle = event.handle;

        special[fix] = {
                setup: function() {
                        jQuery.event.add(this, "focusin.bubbleIE", function( e 
) {
                                jQuery.event.add(e.data == "submit"? 
jQuery(e.target).closest
("form")[0] : e.target, e.data, function( evt ) {
                                        console.log(evt.type);
                                }, undefined, true);
                        }, fix);
                        jQuery.event.add(this, "focusout.bubbleIE", function( e 
) {
                                event.remove(e.data == "submit"? 
jQuery(e.target).closest("form")
[0] : e.target, e.data);
                        }, fix);
                },
                teardown: function() {
                        //jQuery.event.remove(this, ".bubbleIE");
                }
        };
});

And I had to add a "noSpecial" parameter to jQuery.event.add to make
sure that attachEvent is actually called on focusin.
This code work as expected, but as soon as I uncomment the teardown
code or replace my dummy event handler by event.handle , I get "out of
memory" and "stack overflow" errors : (
I'm wondering if it's my installation of IE8 which is buggy or if the
problem is more serious...

The draft of the patch is available as a gist: http://gist.github.com/189976
and I've also built a small test page: http://gist.github.com/189977

If someone else could give it a try that would be great.

On Sep 20, 11:07 pm, lrbabe <lrb...@gmail.com> wrote:
> I actually already started to work on an implementation using focusin
> and focusout, I'll see what kind of results I'm able to get.
> It's a kind of "lazy binding" approach.
>
> On Sep 20, 10:51 pm, John Resig <jere...@gmail.com> wrote:
>
> > Oooh, ok - so I re-read the code and I think I understand it now.
> > Interesting that they use activate/deactivate instead of focusin/focusout
> > (which is what we use right now). That seems to be the secret sauce. The
> > browser detection code is sloppy and the fact that a handler is bound to
> > body regardless of it the events are looked for is lame - either way I think
> > we may be able to make use of this technique.
>
> > --John
>
> > On Sun, Sep 20, 2009 at 11:26 AM, lrbabe <lrb...@gmail.com> wrote:
>
> > > The principle of Reglib is to always work for existing and future
> > > elements.
> > > Those events rely on a bubbling implementation of focus, something
> > > that we already have in trunk and works pretty well.
>
> > > On Sep 20, 4:20 pm, John Resig <jere...@gmail.com> wrote:
> > > > Doesn't that run contrary to the idea behind the live method? In that 
> > > > you
> > > > can bind an event to any element that currently exists and will exist?
> > > This
> > > > is really a non-solution, unfortunately.
>
> > > > --John
>
> > > > On Sun, Sep 20, 2009 at 9:43 AM, lrbabe <lrb...@gmail.com> wrote:
>
> > > > > Hello everybody,
>
> > > > > I know that before releasing jQuery 1.4 it is expected that all events
> > > > > should be compatible with .live()
> > > > > I had a look at the patch related to submit, proposed by Justin Meyer:
> > > > >http://dev.jquery.com/ticket/5267
> > > > > and I am afraid by the possibility that all of these events could
> > > > > require such a complex implementation.
>
> > > > > I would just like to draw your attention toward the choice made by
> > > > > Greg Reimer in Reglib:
> > > > >http://code.google.com/p/reglib/source/browse/trunk/reg.js#1115
>
> > > > > He actually binds "delegated" event handlers to an individual form
> > > > > element when it receives focus, since (according to him) this event is
> > > > > guaranteed to happen first.
> > > > > It might not be a better solution (I'm not sure there is a perfect
> > > > > solution unfortunately) but it might be cleaner.
>
> > > > > What do you think about it?
>
> > > > > Regards,
>
> > > > > Louis-Rémi Babé
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@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