<?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/"
xmlns:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: Adding Events to Adding Events in&#160;MooTools</title> <atom:link href="http://davidwalsh.name/mootools-add-event/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/mootools-add-event</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Wed, 23 May 2012 13:11:42 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Tim John</title><link>http://davidwalsh.name/mootools-add-event#comment-21410</link> <dc:creator>Tim John</dc:creator> <pubDate>Thu, 25 Nov 2010 15:48:26 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2848#comment-21410</guid> <description>Nice one David. I totally agree that the finger cursor is there to indicate clickability, so I&#039;m using your code in my library from now on. Thanks!</description> <content:encoded><![CDATA[<p>Nice one David. I totally agree that the finger cursor is there to indicate clickability, so I&#8217;m using your code in my library from now on. Thanks!</p> ]]></content:encoded> </item> <item><title>By: Simon</title><link>http://davidwalsh.name/mootools-add-event#comment-16049</link> <dc:creator>Simon</dc:creator> <pubDate>Wed, 10 Feb 2010 23:07:35 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2848#comment-16049</guid> <description>This is a great little script but it completely fails you if you use Event Delegation.Your adding cursor pointer to, for example an entire list or the parent UL, instead of the list elements LI.I have one app that uses a click event on the body of the document and delegates the events depending on what div you clicked. So the entire document now has a pointer cursor.So be warned if you use Delegation techniques.</description> <content:encoded><![CDATA[<p>This is a great little script but it completely fails you if you use Event Delegation.</p><p>Your adding cursor pointer to, for example an entire list or the parent UL, instead of the list elements LI.</p><p>I have one app that uses a click event on the body of the document and delegates the events depending on what div you clicked. So the entire document now has a pointer cursor.</p><p>So be warned if you use Delegation techniques.</p> ]]></content:encoded> </item> <item><title>By: Patrick</title><link>http://davidwalsh.name/mootools-add-event#comment-11447</link> <dc:creator>Patrick</dc:creator> <pubDate>Fri, 21 Aug 2009 12:21:15 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2848#comment-11447</guid> <description>What&#039;s the exact error message? I hope you&#039;re using IE8 to debug this error, or maybe even JSCompanion for IE.</description> <content:encoded><![CDATA[<p>What&#8217;s the exact error message? I hope you&#8217;re using IE8 to debug this error, or maybe even JSCompanion for IE.</p> ]]></content:encoded> </item> <item><title>By: Mattia</title><link>http://davidwalsh.name/mootools-add-event#comment-11406</link> <dc:creator>Mattia</dc:creator> <pubDate>Thu, 20 Aug 2009 07:50:22 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2848#comment-11406</guid> <description>The error happened when I replace the content of a div that contains a DatePicker of ClientCide via an AJAX request. The ID and the &quot;name&quot; of the input text with DatePicker is &quot;end&#095;date&quot;.</description> <content:encoded><![CDATA[<p>The error happened when I replace the content of a div that contains a DatePicker of ClientCide via an AJAX request. The ID and the &#8220;name&#8221; of the input text with DatePicker is &#8220;end&#95;date&#8221;.</p> ]]></content:encoded> </item> <item><title>By: Patrick</title><link>http://davidwalsh.name/mootools-add-event#comment-11403</link> <dc:creator>Patrick</dc:creator> <pubDate>Thu, 20 Aug 2009 00:05:06 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2848#comment-11403</guid> <description>Alright here&#039;s some things I noticed, that every mootools developer should keep in mind (these things were connected to my issues above..):Don&#039;t use names for input fields that might&#039;ve been reserved by mootools already - e.g. &quot;send&quot;!
Explanation: Mootools adds a method &quot;send()&quot; to elements (used with Request) - lots of people like to give their &lt;input type=&quot;submit&quot; /&gt; an additional name, so that they can check for a submitted form in php (if (!empty($&#095;POST[&quot;send&quot;]))...) - now &quot;send&quot; is already taken by mootools, giving this input another property named &quot;send&quot; would require an overwrite of an element property, which IE (no matter which version) will respond to with an &quot;The Object doesn&#039;t support...&quot; error - should be fixed in MooTools 2.0 but for now, simply avoid names or properties with &quot;reserved&quot; names (e.g. use &quot;sent&quot; instead).
Here&#039;s what I came up with for the &quot;adding link-cursor for clickable elements&quot;-trick (works without errors in any IE so far):/* update cursor on add/remove click event */
Element.Events.click = {Element.Events.click = {
base:&#039;click&#039;,
onAdd: function() {
if(this.getStyle &amp;&amp; this.get(&quot;tag&quot;) != &quot;a&quot; &amp;&amp; !this.match(&quot;input[type=text]&quot;) &amp;&amp; !this.match(&quot;input[type=password]&quot;)) {
this.store(&#039;original-cursor&#039;,this.getStyle(&#039;cursor&#039;));
this.setStyle(&#039;cursor&#039;,&#039;pointer&#039;);
}
},
onRemove: function() {
if(this.setStyle &amp;&amp; this.get(&quot;tag&quot;) != &quot;a&quot; &amp;&amp; !this.match(&quot;input[type=text]&quot;) &amp;&amp; !this.match(&quot;input[type=password]&quot;)) {
this.setStyle(&#039;cursor&#039;,this.retrieve(&#039;original-cursor&#039;));
}
}};It&#039;s still rough (the selector could be refined that makes sure that this style-switching only occurs on elements which aren&#039;t links already or aren&#039;t neither an input-element containing text or an input-element containing a password value (which should show a textinput cursor).Somehow (don&#039;t ask me why), this.setStyle (which results in setComputedStyle in IE), won&#039;t work in IE correctly when adding Events to Events, &quot;getStyle&quot; however worked...</description> <content:encoded><![CDATA[<p>Alright here&#8217;s some things I noticed, that every mootools developer should keep in mind (these things were connected to my issues above..):</p><p>Don&#8217;t use names for input fields that might&#8217;ve been reserved by mootools already &#8211; e.g. &#8220;send&#8221;!<br
/> Explanation: Mootools adds a method &#8220;send()&#8221; to elements (used with Request) &#8211; lots of people like to give their &lt;input type=&#8221;submit&#8221; /&gt; an additional name, so that they can check for a submitted form in php (if (!empty($&#95;POST["send"]))&#8230;) &#8211; now &#8220;send&#8221; is already taken by mootools, giving this input another property named &#8220;send&#8221; would require an overwrite of an element property, which IE (no matter which version) will respond to with an &#8220;The Object doesn&#8217;t support&#8230;&#8221; error &#8211; should be fixed in MooTools 2.0 but for now, simply avoid names or properties with &#8220;reserved&#8221; names (e.g. use &#8220;sent&#8221; instead).<br
/> Here&#8217;s what I came up with for the &#8220;adding link-cursor for clickable elements&#8221;-trick (works without errors in any IE so far):</p><p>/* update cursor on add/remove click event */<br
/> Element.Events.click = {</p><p>Element.Events.click = {<br
/> base:&#8217;click&#8217;,<br
/> onAdd: function() {<br
/> if(this.getStyle &amp;&amp; this.get(&#8220;tag&#8221;) != &#8220;a&#8221; &amp;&amp; !this.match(&#8220;input[type=text]&#8220;) &amp;&amp; !this.match(&#8220;input[type=password]&#8220;)) {<br
/> this.store(&#8216;original-cursor&#8217;,this.getStyle(&#8216;cursor&#8217;));<br
/> this.setStyle(&#8216;cursor&#8217;,'pointer&#8217;);<br
/> }<br
/> },<br
/> onRemove: function() {<br
/> if(this.setStyle &amp;&amp; this.get(&#8220;tag&#8221;) != &#8220;a&#8221; &amp;&amp; !this.match(&#8220;input[type=text]&#8220;) &amp;&amp; !this.match(&#8220;input[type=password]&#8220;)) {<br
/> this.setStyle(&#8216;cursor&#8217;,this.retrieve(&#8216;original-cursor&#8217;));<br
/> }<br
/> }</p><p>};</p><p>It&#8217;s still rough (the selector could be refined that makes sure that this style-switching only occurs on elements which aren&#8217;t links already or aren&#8217;t neither an input-element containing text or an input-element containing a password value (which should show a textinput cursor).</p><p>Somehow (don&#8217;t ask me why), this.setStyle (which results in setComputedStyle in IE), won&#8217;t work in IE correctly when adding Events to Events, &#8220;getStyle&#8221; however worked&#8230;</p> ]]></content:encoded> </item> <item><title>By: Mattia</title><link>http://davidwalsh.name/mootools-add-event#comment-11384</link> <dc:creator>Mattia</dc:creator> <pubDate>Wed, 19 Aug 2009 08:48:43 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2848#comment-11384</guid> <description>@Patrick: I&#039;ve the error that you explained on Internet Explorer 8 but I don&#039;t understand how I can solve it.</description> <content:encoded><![CDATA[<p>@Patrick: I&#8217;ve the error that you explained on Internet Explorer 8 but I don&#8217;t understand how I can solve it.</p> ]]></content:encoded> </item> <item><title>By: Patrick</title><link>http://davidwalsh.name/mootools-add-event#comment-10553</link> <dc:creator>Patrick</dc:creator> <pubDate>Tue, 21 Jul 2009 19:16:49 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2848#comment-10553</guid> <description>Hey David, really liked that small example for the expandability in mootools.Using a similar bunch of code in a commercial project led to 3 hours of JS-debugging here however - let me explain:I extended the click-Event in the same way you did, but added an additional check for the tagname of the element (don&#039;t need to add a click-cursor, if the element in question is an &lt;a&gt;-element (when using makeResizable on such an element, you&#039;ll lose the resize-cursor if you don&#039;t fix this).Everything went fine in Firefox and Webkit, but in IE8 it all fell apart. I&#039;m still trying to find out, what combination of code let to this error, but long story short:IE8 halted JS-execution because of an error in the mootools-core.js - this line of code:getComputedStyle: function(property){
if (this.currentStyle) return this.currentStyle[property.camelCase()];
var computed = this.getDocument().defaultView.getComputedStyle(this, null);
return (computed) ? computed.getPropertyValue([property.hyphenate()]) : null;
}, &quot;);As we all know, IE has some problems with getProperty and setProperty on elements that weren&#039;t in the original DOM the server sent to the browser. Now as the bad boy that I am, I created my own mootools class for notification boxes. They can be dragged, resized, closed or they can be tooltops, little popups showing where something went wrong on the website with a litte arrowhead, you name it. Beautiful thing, just one class I could do all this stuff with.This class is created before the DOM is loaded, but not instantiated (important difference) - two instances are then created when the domReady-event is fired. But somewhere between creating the instances and adding the event to the click-event, IE8 seems to crumble. If I&#039;m moving your part of the code to the domReady-event, nothing changes, the only &quot;fix&quot;, was using an IE-browserdetection and hiding this particular piece of code from IE..It&#039;s as if IE is already firing the onAdd-event even though the DOM hasn&#039;t been loaded yet (read: IE seems to evaluate the initialize()-method of my class before it&#039;s even instantiated).So nothing left to say but &quot;Beware of IE!&quot; - if you&#039;d like to see the code that brought IE to its knees (even though it&#039;s all working fine in every other browser), feel free to contact me!</description> <content:encoded><![CDATA[<p>Hey David, really liked that small example for the expandability in mootools.</p><p>Using a similar bunch of code in a commercial project led to 3 hours of JS-debugging here however &#8211; let me explain:</p><p>I extended the click-Event in the same way you did, but added an additional check for the tagname of the element (don&#8217;t need to add a click-cursor, if the element in question is an &lt;a&gt;-element (when using makeResizable on such an element, you&#8217;ll lose the resize-cursor if you don&#8217;t fix this).</p><p>Everything went fine in Firefox and Webkit, but in IE8 it all fell apart. I&#8217;m still trying to find out, what combination of code let to this error, but long story short:</p><p>IE8 halted JS-execution because of an error in the mootools-core.js &#8211; this line of code:</p><p>getComputedStyle: function(property){<br
/> if (this.currentStyle) return this.currentStyle[property.camelCase()];<br
/> var computed = this.getDocument().defaultView.getComputedStyle(this, null);<br
/> return (computed) ? computed.getPropertyValue([property.hyphenate()]) : null;<br
/> }, &#8220;);</p><p>As we all know, IE has some problems with getProperty and setProperty on elements that weren&#8217;t in the original DOM the server sent to the browser. Now as the bad boy that I am, I created my own mootools class for notification boxes. They can be dragged, resized, closed or they can be tooltops, little popups showing where something went wrong on the website with a litte arrowhead, you name it. Beautiful thing, just one class I could do all this stuff with.</p><p>This class is created before the DOM is loaded, but not instantiated (important difference) &#8211; two instances are then created when the domReady-event is fired. But somewhere between creating the instances and adding the event to the click-event, IE8 seems to crumble. If I&#8217;m moving your part of the code to the domReady-event, nothing changes, the only &#8220;fix&#8221;, was using an IE-browserdetection and hiding this particular piece of code from IE..</p><p>It&#8217;s as if IE is already firing the onAdd-event even though the DOM hasn&#8217;t been loaded yet (read: IE seems to evaluate the initialize()-method of my class before it&#8217;s even instantiated).</p><p>So nothing left to say but &#8220;Beware of IE!&#8221; &#8211; if you&#8217;d like to see the code that brought IE to its knees (even though it&#8217;s all working fine in every other browser), feel free to contact me!</p> ]]></content:encoded> </item> <item><title>By: Иван</title><link>http://davidwalsh.name/mootools-add-event#comment-9912</link> <dc:creator>Иван</dc:creator> <pubDate>Thu, 18 Jun 2009 00:06:49 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2848#comment-9912</guid> <description>(I like the idea very much. It&#039;s just some thought I have on it.)I strongly believe that the design should appeal to the user for interaction -- if something can be interacted (click, drag, resize -- you name it) with, it should have the proper cursor set, regardless of whether the interaction came from progressive enhancement or not.In the case of the front end getting the job right and the user still not being able to grasp where is the clickable area, the user is:a) extremely dumb
b) born in the early 19th century and is currently worshiping the big (even bigger if it is a CRT) black boxHowever, one can never be sure (that the front end did job right) so this might come in handy.</description> <content:encoded><![CDATA[<p>(I like the idea very much. It&#8217;s just some thought I have on it.)</p><p>I strongly believe that the design should appeal to the user for interaction &#8212; if something can be interacted (click, drag, resize &#8212; you name it) with, it should have the proper cursor set, regardless of whether the interaction came from progressive enhancement or not.</p><p>In the case of the front end getting the job right and the user still not being able to grasp where is the clickable area, the user is:</p><p>a) extremely dumb<br
/> b) born in the early 19th century and is currently worshiping the big (even bigger if it is a CRT) black box</p><p>However, one can never be sure (that the front end did job right) so this might come in handy.</p> ]]></content:encoded> </item> <item><title>By: Paul Spencer</title><link>http://davidwalsh.name/mootools-add-event#comment-9805</link> <dc:creator>Paul Spencer</dc:creator> <pubDate>Mon, 15 Jun 2009 23:42:59 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2848#comment-9805</guid> <description>Fantastic!  When I tried this, it worked perfectly except that I have some code that adds a &#039;click&#039; event handler to the document when a popup opens so that it closes if the user clicks outside the popup and document.setStyle doesn&#039;t exist - so I added if (this.setStyle) {} around the code to make it work for me.</description> <content:encoded><![CDATA[<p>Fantastic!  When I tried this, it worked perfectly except that I have some code that adds a &#8216;click&#8217; event handler to the document when a popup opens so that it closes if the user clicks outside the popup and document.setStyle doesn&#8217;t exist &#8211; so I added if (this.setStyle) {} around the code to make it work for me.</p> ]]></content:encoded> </item> <item><title>By: DJ</title><link>http://davidwalsh.name/mootools-add-event#comment-9804</link> <dc:creator>DJ</dc:creator> <pubDate>Mon, 15 Jun 2009 22:07:01 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2848#comment-9804</guid> <description>Looks like endrew&#039;s pointed you to it and jQ&#039;s got the right stuff. How about a jQ version?</description> <content:encoded><![CDATA[<p>Looks like endrew&#8217;s pointed you to it and jQ&#8217;s got the right stuff. How about a jQ version?</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching using disk: basic
Object Caching 804/805 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-23 08:44:51 -->
