[jQuery] Binding events

[jQuery] Binding events

Hi,
Playing with jquery and jquery-dom, I modified the latter to handle
events in params:
In the attrs loop of _createNode:
    e[a] = attrs[attr];
becomes:
    if (attrs[attr].constructor == Function) {
        addEvent(e, a, attrs[attr]);
    } else {
        e[a] = attrs[attr];
    }
With this modification, I can create nodes like that:
    for (var i=0; i<items.length; ++i) {
        var item=items[i];
        $('#x').append(
            $.DIV(
                {'id':'_'+i, 'click':myFunc},
                'item #'+i
            )
        );
    }
    function myFunc(e) {
        alert(this.id);
        return false;
    }
This way, I save queries to bind events but, I don't know why, I'm not
sure it's a good idea... any thoughts?
Franck.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/