is it appropriate to use $(this).addClass instead of $(e.target).addClass
inside the handler? it seems to work using $(this) but i'm not sure if
that's the intended implementation.
In most cases, the this and e.target are the same element. They are
only different if you set the indexer to be
i did the event delegation by hand and it's pretty easy.
(tbody).click(myHandler);
function myHandler(e) {
var e = e || window.event;
var elem = e.target || e.srcElement;
if (elem.nodeName.toLowerCase() == td) {
// do stuff
}
}
however, the jQuery Listen plugin is much more
On Mar 31, 9:56 am, Leeoniya [EMAIL PROTECTED] wrote:
i did the event delegation by hand and it's pretty easy.
(tbody).click(myHandler);
function myHandler(e) {
var e = e || window.event;
var elem = e.target || e.srcElement;
if (elem.nodeName.toLowerCase() == td) {
// do stuff
with the Listen plugin i have something like this:
$(tbody).listen(click, td, function(e) {
$(this).addClass(edit).html(input type='text' /);
$(input, $(this)).each(function() {$(this).focus()});
})
is it appropriate to use $(this).addClass instead of $(e.target).addClass
inside the
always heard the term, never really explored it; I think i have a lot more
refactoring to do now :)
Klaus Hartl-4 wrote:
I think in this case it is better to use event delegation, e.g. set up
a single handler on the parent table element and handle the click
here. You can get to the
Hi Leeoniya,
I'm not sure exactly what you are trying to do, but I've got a large
table, and when a user clicks on a cell, i pass the id of that cell to
a function. No binding, no inline functions.
mine works like this, i hope it helps, though it is pretty basic.
[code]
I'm not sure exactly what you are getting at, maybe describing what
you are trying to do would help.
I have a table that when the user selects certain cells, they are
provided with forms, options, moves, etc. (currently being built, so I
can't point you to it).
Rather than binding to each cell,
Hey Leeoniya,
I'm not sure exactly what you are trying to do, but I think binding
each cell to an external function, or creating an 'anonymous' function
inline maybe isn't the best way to go.
I have a table with lots of cells, and when the user clicks on a cell,
i pass the id of that cell to a
If you have thousands of td's, that code is going to be very very slow. It
makes an array of all the TD elements and then attaches an event handler to
every one of them, one by one.
You would get *much* better performance by attaching a single event handler
to the table itself, then using
I think in this case it is better to use event delegation, e.g. set up
a single handler on the parent table element and handle the click
here. You can get to the clicked cell via e.target.
--Klaus
On Mar 28, 5:25 pm, Leeoniya [EMAIL PROTECTED] wrote:
i need to bind a click function to
10 matches
Mail list logo