Well, after a few tests, this works fine :
$(#cat_list div).live(click, function()
{ alert($(this).attr(id));
});
thanx
I wouldn't suggest going the .live route if you plan on having a lot
of children of cat_list
using event delegation, there is one single event wired up that
handles 1 child or 1200 children
using .live, you would have N number of events sitting there wired
up where N is the number of
On Dec 4, 2009, at 11:09 AM, MorningZ wrote:
I wouldn't suggest going the .live route if you plan on having a lot
of children of cat_list
using event delegation, there is one single event wired up that
handles 1 child or 1200 children
using .live, you would have N number of events
Well I dont think I'll have more than about 15 childs here.
Thx for help
On 4 déc, 17:09, MorningZ morni...@gmail.com wrote:
I wouldn't suggest going the .live route if you plan on having a lot
of children of cat_list
using event delegation, there is one single event wired up that
Nah. Using .live() wires up one event handler to document.
--Karl
Doh, shame on me for my lack of facts on that .live()... i'll read
up on it some, as i usually, well always, take the delegation
route..
The .live() method uses event delegation under the hood. doing this:
$('a').live('click', function() {
// do something
});
is like doing this:
$(document).bind('click', function(event) {
if ($(event.target).closest('a').length) {
// do something
}
});
except that with .live() the
I'm relative new to jQuery, but I usually use function(e) instead of
function() within a click handlers, because when you do it on a
selector that do not return a single element (#cat_list div
returns several dom element) you cannot access the data you need
(e.target is the element you clicked).
the first one works perfectly fine in stripped down form
http://jsbin.com/epoju/edit
must be something else with other code you are doing
On Dec 3, 10:03 am, Civette la.cive...@gmail.com wrote:
Well i'm in trouble.
Following code does not trigger :
Code: Select all
$(#cat_list
Well, actually my div 39, 40, are returned in the cat_list
div from a previous ajax query. Numbers are in fact the autoincrement
id's in a mysql table.
Point is, on clicking each, to edit it.
That specific javascript part is returned by that ajax query.
if those div's are dynamically added, which it sounds like is the
case, then the new div's do not get wired automatically... -
this is easily the most common trip-up seen on this mailing list
Event Delegation would be your friend here
http://jsbin.com/ivivo/edit
that way the container event
I'll test it tomorrow.
Thx for answer
Is your issue description linked to this :
http://forum.jquery.com/viewtopic.php?f=2t=1000sid=7932d86732f0126e2c4ad3f5e92baa4d
Same thing ?
On Dec 3, 10:52 pm, MorningZ morni...@gmail.com wrote:
if those div's are dynamically added, which it sounds like is the
case, then the new div's do not
12 matches
Mail list logo