It seems like a bug, as 1.3.1 is behaving differently from 1.2.6. I posted errant's example to jquery-dev, let's see what they have to say. http://groups.google.com/group/jquery-dev/t/f18e4a06e11fdb87
On Jan 27, 4:01 pm, Eric Garside <gars...@gmail.com> wrote: > I don't think it's a bug. I think it's just another example of IE's > lack of standard compliance. > > On Jan 27, 12:53 pm, errant <d.cheka...@gmail.com> wrote: > > > jQuery provides many ways to achieve similar results, sometimes > > decision which way to use is up to developer. Personally, in first > > example i like to have reference to span element with attached event > > handlers without extra code. Maybe i'll use it in some other way later > > in code. Anyway, append() gives different results in different > > browsers, and it doesn't seems right, right? So far there were no > > response from dev. team, maybe i should post bugreport? > > > On 27 янв, 20:07, Eric Garside <gars...@gmail.com> wrote: > > > > Honestly, I'm at a loss why I'd want that kind of temporary cloned > > > functionality when you could just use live to achieve the same > > > functionality with nowhere near the limitations of the implementation > > > you've described here. It's also nice to be able to excise my event > > > declarations from my dom manipulations. > > > > Again, I can't think of a situation where your method would be better > > > in any way than using a live event. > > > > On Jan 27, 11:37 am, jay <jay.ab...@gmail.com> wrote: > > > > > of course if there are other things that may need to be customized > > > > about the event(s) in question it might make more sense to pass in an > > > > options object. > > > > > On Jan 27, 11:30 am, jay <jay.ab...@gmail.com> wrote: > > > > > > I thought the point was to avoid the each()? What's wrong with: > > > > > > $('ul li').append($('<span>Click me!</span>').click(function(){}, > > > > > true); > > > > > > and doing $('ul li').append($('<span>Click me!</span>').click(function > > > > > (){}); > > > > > > defaults the second argument to false. > > > > > > Or you could default it to true and it may stay more backwards- > > > > > compatible with older versions. > > > > > > On Jan 27, 11:22 am, Eric Garside <gars...@gmail.com> wrote: > > > > > > > You can already do that using clone. I can't see a need to rewrite > > > > > > in > > > > > > new code when the ability already exists in the current code. If you > > > > > > want to clone around your elements around and not apply new styles, > > > > > > just: > > > > > > > $('ul li').each(function(){ > > > > > > $(this).append($('<span>Click me!</span>').click(function(){})) > > > > > > > }); > > > > > > > On Jan 27, 11:14 am, jay <jay.ab...@gmail.com> wrote: > > > > > > > > It's not that I prefer it. I think live()/die() makes sense > > > > > > > because > > > > > > > the event "lives on" for all matching selectors. What the true > > > > > > > arguement would do it give a way to clone the element and it's > > > > > > > handler > > > > > > > just that one time. > > > > > > > > On Jan 27, 10:50 am, Eric Garside <gars...@gmail.com> wrote: > > > > > > > > > Give them a different selector? > > > > > > > > > $('.click1').live('click', function(){}); > > > > > > > > $('.click2').live('click', function(){}); > > > > > > > > > Would handle the problem easily. Remember, you can always add > > > > > > > > extra, > > > > > > > > non-style based classes which you can use as selectors for > > > > > > > > events or > > > > > > > > effects. > > > > > > > > > Also, I'm not sure I understand your objection. If I understand > > > > > > > > correctly, you're saying you'd prefer: > > > > > > > > > var span = $('<span>Click me</span>').click(function(){}, true); > > > > > > > > $('ul li').append(span); > > > > > > > > > Instead of: > > > > > > > > $('ul li span').live('click', function(){}); > > > > > > > > $('ul li').append('<span>Click me</span>'); > > > > > > > > > The live syntax is, at least in this example, shorter, more > > > > > > > > efficient, > > > > > > > > cleaner, and easier to use. Perhaps it's just that I'm not > > > > > > > > understanding a situation in which I'd run into trouble using > > > > > > > > it over > > > > > > > > an object, kept in memory, with a forced clone(true) bound to > > > > > > > > it. Can > > > > > > > > you think of any? > > > > > > > > > On Jan 27, 10:36 am, jay <jay.ab...@gmail.com> wrote: > > > > > > > > > > live() works, but it involves extra steps. For example > > > > > > > > > something like > > > > > > > > > el.click(fn,true) maybe be easier to remember for some. Also > > > > > > > > > live > > > > > > > > > differs from what I was thinking in that it continues to bind > > > > > > > > > events > > > > > > > > > to the handler based on the selector. I was thinking it > > > > > > > > > should only > > > > > > > > > be cloned that one time (with the event handlers included). > > > > > > > > > What if, > > > > > > > > > for some reason, elements of a different type were added to > > > > > > > > > the same > > > > > > > > > "container", but had a different functionality? live() > > > > > > > > > wouldn't > > > > > > > > > necessarily be what you would want. > > > > > > > > > > On Jan 27, 10:15 am, Eric Garside <gars...@gmail.com> wrote: > > > > > > > > > > > > Perhaps there should be an optional boolean passed to the > > > > > > > > > > > event > > > > > > > > > > > handlers to specify carrying over event handlers like > > > > > > > > > > > there is with > > > > > > > > > > > the clone() method? > > > > > > > > > > > There is. That's exactly what live() does. You just define > > > > > > > > > > it before > > > > > > > > > > runtime. > > > > > > > > > > > On Jan 27, 10:06 am, jay <jay.ab...@gmail.com> wrote: > > > > > > > > > > > > It actually makes sense, because you've only created one > > > > > > > > > > > element here: > > > > > > > > > > > > var handle = $('<span>Click me</span>'); > > > > > > > > > > > > By doing append() on a set of elements using this one > > > > > > > > > > > element, it may > > > > > > > > > > > be implying you would like to clone this element for the > > > > > > > > > > > elements > > > > > > > > > > > after the first one, but it's not completely obvious. > > > > > > > > > > > Something that > > > > > > > > > > > may make more sense is that the one element ends up in > > > > > > > > > > > the very last > > > > > > > > > > > <li>. Perhaps there should be an optional boolean passed > > > > > > > > > > > to the event > > > > > > > > > > > handlers to specify carrying over event handlers like > > > > > > > > > > > there is with > > > > > > > > > > > the clone() method? > > > > > > > > > > > > On Jan 27, 9:48 am, errant <d.cheka...@gmail.com> wrote: > > > > > > > > > > > > > Hi Eric, thanks for response. > > > > > > > > > > > > > Yes, it works that way, but it's kind of unflexible and > > > > > > > > > > > > may be > > > > > > > > > > > > impossible to implement when dealing with more complex > > > > > > > > > > > > code, don't you > > > > > > > > > > > > think? > > > > > > > > > > > > > On 27 янв, 17:29, Eric Garside <gars...@gmail.com> > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > I believe it has to do with the new event propogation > > > > > > > > > > > > > model > > > > > > > > > > > > > implemented with 1.3 > > > > > > > > > > > > > > Instead, try using a living event: > > > > > > > > > > > > > > <ul> > > > > > > > > > > > > > <li></li> > > > > > > > > > > > > > <li></li> > > > > > > > > > > > > > <li></li> > > > > > > > > > > > > > <li></li> > > > > > > > > > > > > > <li></li> > > > > > > > > > > > > > </ul> > > > > > > > > > > > > > > $('ul li span').live('click', function(){ > > > > > > > > > > > > > // ... > > > > > > > > > > > > > > }); > > > > > > > > > > > > > > $('ul li').append('<span>Click me</span>'); > > > > > > > > > > > > > > That should work. > > > > > > > > > > > > > > On Jan 27, 8:15 am, errant <d.cheka...@gmail.com> > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > Here is the code: > > > > > > > > > > > > > > > HTML: > > > > > > > > > > > > > > > <ul> > > > > > > > > > > > > > > <li></li> > > > > > > > > > > > > > > <li></li> > > > > > > > > > > > > > > <li></li> > > > > > > > > > > > > > > <li></li> > > > > > > > > > > > > > > <li></li> > > > > > > > > > > > > > > </ul> > > > > > > > > > > > > > > > JS: > > > > > > > > > > > > > > > $(function(){ > > > > > > > > > > > > > > > var handle = $('<span>Click me</span>'); > > > > > > > > > > > > > > handle.click(function() { > > > > > > > > > > > > > > alert('Thanks'); > > > > > > > > > > > > > > }); > > > > > > > > > > > > > > $('ul li').append(handle); > > > > > > > > > > > > > > > }); > > > > > > > > > > > > > > > With jQuery 1.2.6, each time I click on any list's > > > > > > > > > > > > > > element it shows > > > > > > > > > > > > > > alert. With 1.3.1 in FF3, Safari 3 & Opera 9.63 > > > > > > > > > > > > > > alert is only > > > > > > > > > > > > > > displaying when I click on first element. In IE6,7 > > > > > > > > > > > > > > everything is ok. > > > > > > > > > > > > > > Is this some kind of bug?- Hide quoted text - > > > > > > > > > > > > > - Show quoted text -- Hide quoted text - > > > > > > > > > > > - Show quoted text -- Hide quoted text - > > > > > > > > > - Show quoted text -- Hide quoted text - > > > > > > > - Show quoted text -- Hide quoted text - > > > > > > - Show quoted text -