<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: .delegate()</title>
	<atom:link href="http://api.jquery.com/delegate/feed/" rel="self" type="application/rss+xml" />
	<link>http://api.jquery.com/delegate/</link>
	<description>jQuery API Reference</description>
	<lastBuildDate>Fri, 19 Aug 2011 09:06:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Crunksounds</title>
		<link>http://api.jquery.com/delegate/comment-page-1/#comment-8243</link>
		<dc:creator>Crunksounds</dc:creator>
		<pubDate>Tue, 11 Jan 2011 09:09:37 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=1821#comment-8243</guid>
		<description>&lt;a href=&quot;https://github.com/brandonaaron/livequery&quot; rel=&quot;nofollow&quot;&gt;https://github.com/brandonaaro...&lt;/a&gt;&lt;br&gt;&lt;br&gt;LIVE QUERY = WIN!!</description>
		<content:encoded><![CDATA[<p><a href="https://github.com/brandonaaron/livequery" rel="nofollow">https://github.com/brandonaaro&#8230;</a></p>
<p>LIVE QUERY = WIN!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radek Pleskac</title>
		<link>http://api.jquery.com/delegate/comment-page-1/#comment-6204</link>
		<dc:creator>Radek Pleskac</dc:creator>
		<pubDate>Fri, 08 Oct 2010 04:39:09 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=1821#comment-6204</guid>
		<description>Hi,&lt;br&gt;&lt;br&gt;is there a way to delegate multiple events of the same type, and all of them are gonna work?&lt;br&gt;When I lets say bind multiple clicks to an element, all of the clicks trigger, but when I delegate multiple clicks for an element only the first one is triggered.&lt;br&gt;&lt;br&gt;When I look at the events bound in fireQuery, I can se the events are bound to the element, but all of them won&#039;t fire, just the first one.&lt;br&gt;&lt;br&gt;Thanks Radek</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>is there a way to delegate multiple events of the same type, and all of them are gonna work?<br />When I lets say bind multiple clicks to an element, all of the clicks trigger, but when I delegate multiple clicks for an element only the first one is triggered.</p>
<p>When I look at the events bound in fireQuery, I can se the events are bound to the element, but all of them won&#39;t fire, just the first one.</p>
<p>Thanks Radek</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chicagoworks</title>
		<link>http://api.jquery.com/delegate/comment-page-1/#comment-12377</link>
		<dc:creator>chicagoworks</dc:creator>
		<pubDate>Tue, 21 Sep 2010 15:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=1821#comment-12377</guid>
		<description>Try this... it overrides delegate(), if &#039;selector&#039; is an object it loops over the object and calls .live() 
for each item, otherwise it calls .live() just like the original .delegate(). It&#039;s roughly similar to the 
way the map is implemented in .bind().

//OVERRIDE DELEGATE 
(function($) {
    $.fn.delegate = function(selector, types, data, fn) {
        if (typeof selector === &quot;object&quot;) {
            for (var sel in selector) {
                for (var type in selector[sel]) {
                    this.live(type, data, selector[sel][type], sel);
                }
            }
            return this;
        } else {
            return this.live(types, data, fn, selector);
        }
    };
})(jQuery);

//SAMPLE USAGE
//call delegate with an object map of selectors, events and function
//NOTE: data object is the second parameter
$(&#039;#header&#039;).delegate({
    &#039;img&#039; : {
        &#039;click dblclick&#039;:function(){
                console.log(&#039;clicked&#039;)
        }
    },
    &#039;li&#039; : {
        mouseover:function(){
            console.log(&#039;over&#039;)
        },
        mouseout:function(){
            console.log(&#039;out&#039;)
        }
    }
}, {foo:123 , bar:456});

//test regular delegate call
$(&#039;#header&#039;).delegate(&#039;img&#039;, &#039;click dblclick&#039;, function click(){
    console.log(&#039;clicked&#039;)
    });

//test regular delegate call with a data object
$(&#039;#header&#039;).delegate(&#039;img&#039;, &#039;click dblclick&#039;, {foo:123 , bar:456}, function click(){
    console.log(&#039;clicked&#039;)
    });
</description>
		<content:encoded><![CDATA[<p>Try this&#8230; it overrides delegate(), if &#8216;selector&#8217; is an object it loops over the object and calls .live()<br />
for each item, otherwise it calls .live() just like the original .delegate(). It&#8217;s roughly similar to the<br />
way the map is implemented in .bind().</p>
<p>//OVERRIDE DELEGATE<br />
(function($) {<br />
    $.fn.delegate = function(selector, types, data, fn) {<br />
        if (typeof selector === &#8220;object&#8221;) {<br />
            for (var sel in selector) {<br />
                for (var type in selector[sel]) {<br />
                    this.live(type, data, selector[sel][type], sel);<br />
                }<br />
            }<br />
            return this;<br />
        } else {<br />
            return this.live(types, data, fn, selector);<br />
        }<br />
    };<br />
})(jQuery);</p>
<p>//SAMPLE USAGE<br />
//call delegate with an object map of selectors, events and function<br />
//NOTE: data object is the second parameter<br />
$(&#8216;#header&#8217;).delegate({<br />
    &#8216;img&#8217; : {<br />
        &#8216;click dblclick&#8217;:function(){<br />
                console.log(&#8216;clicked&#8217;)<br />
        }<br />
    },<br />
    &#8216;li&#8217; : {<br />
        mouseover:function(){<br />
            console.log(&#8216;over&#8217;)<br />
        },<br />
        mouseout:function(){<br />
            console.log(&#8216;out&#8217;)<br />
        }<br />
    }<br />
}, {foo:123 , bar:456});</p>
<p>//test regular delegate call<br />
$(&#8216;#header&#8217;).delegate(&#8216;img&#8217;, &#8216;click dblclick&#8217;, function click(){<br />
    console.log(&#8216;clicked&#8217;)<br />
    });</p>
<p>//test regular delegate call with a data object<br />
$(&#8216;#header&#8217;).delegate(&#8216;img&#8217;, &#8216;click dblclick&#8217;, {foo:123 , bar:456}, function click(){<br />
    console.log(&#8216;clicked&#8217;)<br />
    });</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sid_M</title>
		<link>http://api.jquery.com/delegate/comment-page-1/#comment-5377</link>
		<dc:creator>Sid_M</dc:creator>
		<pubDate>Sun, 05 Sep 2010 22:40:58 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=1821#comment-5377</guid>
		<description>Try jQuery(&#039;#mydiv&#039;).delegate(&#039;#mydiv &gt; p&#039;, &#039;click&#039;, function() { &lt;br&gt;  console.log(this.innerHTML);&lt;br&gt;});</description>
		<content:encoded><![CDATA[<p>Try jQuery(&#39;#mydiv&#39;).delegate(&#39;#mydiv &gt; p&#39;, &#39;click&#39;, function() { <br />  console.log(this.innerHTML);<br />});</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wilsonmacariano</title>
		<link>http://api.jquery.com/delegate/comment-page-1/#comment-12206</link>
		<dc:creator>Wilsonmacariano</dc:creator>
		<pubDate>Wed, 25 Aug 2010 04:50:00 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=1821#comment-12206</guid>
		<description>Hey Marcus! Thank you very much for the tip! I have been looking for this solution sometime ago and i just could not find it! Thank you! =]</description>
		<content:encoded><![CDATA[<p>Hey Marcus! Thank you very much for the tip! I have been looking for this solution sometime ago and i just could not find it! Thank you! =]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl Swedberg</title>
		<link>http://api.jquery.com/delegate/comment-page-1/#comment-5118</link>
		<dc:creator>Karl Swedberg</dc:creator>
		<pubDate>Tue, 24 Aug 2010 23:09:26 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=1821#comment-5118</guid>
		<description>You might want to look into the livequery plugin. It doesn&#039;t &lt;em&gt;delegate&lt;/em&gt; to future elements, but it does &lt;em&gt;bind&lt;/em&gt; to them:&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://github.com/brandonaaron/livequery&quot; rel=&quot;nofollow&quot;&gt;http://github.com/brandonaaron/livequery&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>You might want to look into the livequery plugin. It doesn&#39;t <em>delegate</em> to future elements, but it does <em>bind</em> to them:</p>
<p><a href="http://github.com/brandonaaron/livequery" rel="nofollow">http://github.com/brandonaaron/livequery</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcus Kabele</title>
		<link>http://api.jquery.com/delegate/comment-page-1/#comment-5045</link>
		<dc:creator>Marcus Kabele</dc:creator>
		<pubDate>Sat, 21 Aug 2010 13:58:50 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=1821#comment-5045</guid>
		<description>FYI: take care when you want to delegate .hover() == .mouseenter().mouseleave()&lt;br&gt;&lt;br&gt;You have to use the (problematic) &quot;mouseover mouseout&quot; events:&lt;br&gt;.delegate(&quot;.hover&quot;,&quot;mouseover mouseout&quot;, function(event) {&lt;br&gt;   if (event.type == &#039;mouseover&#039;) { ...&lt;br&gt;&lt;br&gt;.delegate(&quot;.hover&quot;,&quot;mouseenter mouseleave&quot;, ... is not supported by standard browsers.&lt;br&gt;jQuery emulates these proprietary events in .mouseenter() and .mouseleave(), but they are not fired as events in modern browsers (and jQuery 1.4.2).&lt;br&gt;&lt;br&gt;.delegate(&quot;.hover&quot;, &quot;hover&quot;, ... only provides the single-function toggle functionality.&lt;br&gt;&lt;br&gt;The same is true for .live()</description>
		<content:encoded><![CDATA[<p>FYI: take care when you want to delegate .hover() == .mouseenter().mouseleave()</p>
<p>You have to use the (problematic) &#8220;mouseover mouseout&#8221; events:<br />.delegate(&#8220;.hover&#8221;,&#8221;mouseover mouseout&#8221;, function(event) {<br />   if (event.type == &#39;mouseover&#39;) { &#8230;</p>
<p>.delegate(&#8220;.hover&#8221;,&#8221;mouseenter mouseleave&#8221;, &#8230; is not supported by standard browsers.<br />jQuery emulates these proprietary events in .mouseenter() and .mouseleave(), but they are not fired as events in modern browsers (and jQuery 1.4.2).</p>
<p>.delegate(&#8220;.hover&#8221;, &#8220;hover&#8221;, &#8230; only provides the single-function toggle functionality.</p>
<p>The same is true for .live()</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Elliott</title>
		<link>http://api.jquery.com/delegate/comment-page-1/#comment-12093</link>
		<dc:creator>Bryan Elliott</dc:creator>
		<pubDate>Fri, 13 Aug 2010 14:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=1821#comment-12093</guid>
		<description>You&#039;re also gaining a certain amount of error avoidance with the live-like functionality that delegate brings (i.e., futzing with the DOM doesn&#039;t leave your carefully crafted behaviors dead), but without every event bubbling all the way back to the documentElement.  It&#039;s kind of a performant trade-off for scripts that will have some idea of the document structure (i.e., anything site- or tool-specific).</description>
		<content:encoded><![CDATA[<p>You&#8217;re also gaining a certain amount of error avoidance with the live-like functionality that delegate brings (i.e., futzing with the DOM doesn&#8217;t leave your carefully crafted behaviors dead), but without every event bubbling all the way back to the documentElement.  It&#8217;s kind of a performant trade-off for scripts that will have some idea of the document structure (i.e., anything site- or tool-specific).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Elliott</title>
		<link>http://api.jquery.com/delegate/comment-page-1/#comment-4876</link>
		<dc:creator>Bryan Elliott</dc:creator>
		<pubDate>Fri, 13 Aug 2010 11:49:11 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=1821#comment-4876</guid>
		<description>From a performance standpoint, it&#039;s kind of trivial to flip an object (i.e., O(xy) for a nominally small x and y), so it&#039;s probably best to go with what&#039;s logical from the library consumer&#039;s point of view - i.e., obj[selector][event], and let the library mangle the input however it needs to.</description>
		<content:encoded><![CDATA[<p>From a performance standpoint, it&#39;s kind of trivial to flip an object (i.e., O(xy) for a nominally small x and y), so it&#39;s probably best to go with what&#39;s logical from the library consumer&#39;s point of view &#8211; i.e., obj[selector][event], and let the library mangle the input however it needs to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kassapa</title>
		<link>http://api.jquery.com/delegate/comment-page-1/#comment-12049</link>
		<dc:creator>Kassapa</dc:creator>
		<pubDate>Tue, 10 Aug 2010 04:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://api.jquery.com/?p=1821#comment-12049</guid>
		<description>yes. delegating the event to the body would do the the work. But it would be nice if it is possible to delegate it to a future element as well; but I&#039;m in doubt if it is possible.</description>
		<content:encoded><![CDATA[<p>yes. delegating the event to the body would do the the work. But it would be nice if it is possible to delegate it to a future element as well; but I&#8217;m in doubt if it is possible.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

