[jQuery] Re: Selector issue

2009-12-04 Thread Civette
Well, after a few tests, this works fine : $(#cat_list div).live(click, function() { alert($(this).attr(id)); }); thanx

[jQuery] Re: Selector issue

2009-12-04 Thread MorningZ
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

Re: [jQuery] Re: Selector issue

2009-12-04 Thread Karl Swedberg
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

[jQuery] Re: Selector issue

2009-12-04 Thread Civette
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

[jQuery] Re: Selector issue

2009-12-04 Thread MorningZ
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..

Re: [jQuery] Re: Selector issue

2009-12-04 Thread Karl Swedberg
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

[jQuery] Re: Selector issue

2009-12-03 Thread RiccardoC
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).

[jQuery] Re: Selector issue

2009-12-03 Thread MorningZ
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

[jQuery] Re: Selector issue

2009-12-03 Thread Civette
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.

[jQuery] Re: Selector issue

2009-12-03 Thread MorningZ
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

[jQuery] Re: Selector issue

2009-12-03 Thread Civette
I'll test it tomorrow. Thx for answer

[jQuery] Re: Selector issue

2009-12-03 Thread Civette
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