<?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: Workaround: Form Submit Method Doesn&#8217;t Fire Submit Event</title>
	<atom:link href="http://briancrescimanno.com/2009/05/14/form-submit-method-doesnt-fire-submit-event-workaround/feed/" rel="self" type="application/rss+xml" />
	<link>http://briancrescimanno.com/2009/05/14/form-submit-method-doesnt-fire-submit-event-workaround/</link>
	<description>Thoughts on Web Design, Development, and Applications</description>
	<lastBuildDate>Mon, 08 Mar 2010 22:52:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Brian</title>
		<link>http://briancrescimanno.com/2009/05/14/form-submit-method-doesnt-fire-submit-event-workaround/comment-page-1/#comment-416</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Wed, 01 Jul 2009 18:23:43 +0000</pubDate>
		<guid isPermaLink="false">http://briancrescimanno.com/?p=57#comment-416</guid>
		<description>Hi Paul,

I&#039;m glad you found this solution helpful!  Two things:

1.  Yes, that was a typo.

2.  In my original implementation, the two functions were not identical due to a mistake on my part in the implementation for IE (that worked about 50% of the time).  When I went back and corrected the problem, I didn&#039;t look to see if the two were identical (which, minus the typo, they were indeed).</description>
		<content:encoded><![CDATA[<p>Hi Paul,</p>
<p>I&#8217;m glad you found this solution helpful!  Two things:</p>
<p>1.  Yes, that was a typo.</p>
<p>2.  In my original implementation, the two functions were not identical due to a mistake on my part in the implementation for IE (that worked about 50% of the time).  When I went back and corrected the problem, I didn&#8217;t look to see if the two were identical (which, minus the typo, they were indeed).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Hinze</title>
		<link>http://briancrescimanno.com/2009/05/14/form-submit-method-doesnt-fire-submit-event-workaround/comment-page-1/#comment-415</link>
		<dc:creator>Paul Hinze</dc:creator>
		<pubDate>Wed, 01 Jul 2009 18:18:21 +0000</pubDate>
		<guid isPermaLink="false">http://briancrescimanno.com/?p=57#comment-415</guid>
		<description>Nice article; this is exactly the problem I&#039;m dealing with today.  Well written with a solid solution.

I notice that in your code you are form a &#039;form:submit&#039; event for DOM compliant browsers and a &#039;fake:submit&#039; event for IE.  I believe this is a typo?

In in the process of incorporating this to my project, I made a couple of additional tweaks.  (1) I added the ability to stop the event in one of the handlers; the browser submit fires either way in the above code.  (2) The inline function you use to attach to each form is (if my above typo assumption is correct) identical to fakeSubmit, so I just use a reference to that function which is a bit more DRY.

Here is the revised code:


function fakeSubmit(event) {
    var target = event ? event.target : this;
    /* Fire a submit event */
    var fakeEvent = $(target).fire(&quot;form:submit&quot;);
    if (fakeEvent.stopped == false) {
      /* Call the real submit function */
      this._submit();
    }
}

if(window.HTMLElement){
    /* DOM-compliant Browsers */
    HTMLFormElement.prototype._submit = HTMLFormElement.prototype.submit;
    HTMLFormElement.prototype.submit = fakeSubmit;
} else {
    /* IE does not expose it&#039;s HTMLElement object or its children
        Let the document load so all forms are accounted for */
    document.observe(&quot;dom:loaded&quot;, function(){
        for(var i = 0; i &lt; document.forms.length; i  ){
            document.forms[i]._submit = document.forms[i].submit;
            document.forms[i].submit  = fakeSubmit;
        }
    });
}
</description>
		<content:encoded><![CDATA[<p>Nice article; this is exactly the problem I&#8217;m dealing with today.  Well written with a solid solution.</p>
<p>I notice that in your code you are form a &#8216;form:submit&#8217; event for DOM compliant browsers and a &#8216;fake:submit&#8217; event for IE.  I believe this is a typo?</p>
<p>In in the process of incorporating this to my project, I made a couple of additional tweaks.  (1) I added the ability to stop the event in one of the handlers; the browser submit fires either way in the above code.  (2) The inline function you use to attach to each form is (if my above typo assumption is correct) identical to fakeSubmit, so I just use a reference to that function which is a bit more DRY.</p>
<p>Here is the revised code:</p>
<p>function fakeSubmit(event) {<br />
    var target = event ? event.target : this;<br />
    /* Fire a submit event */<br />
    var fakeEvent = $(target).fire(&#8220;form:submit&#8221;);<br />
    if (fakeEvent.stopped == false) {<br />
      /* Call the real submit function */<br />
      this._submit();<br />
    }<br />
}</p>
<p>if(window.HTMLElement){<br />
    /* DOM-compliant Browsers */<br />
    HTMLFormElement.prototype._submit = HTMLFormElement.prototype.submit;<br />
    HTMLFormElement.prototype.submit = fakeSubmit;<br />
} else {<br />
    /* IE does not expose it&#8217;s HTMLElement object or its children<br />
        Let the document load so all forms are accounted for */<br />
    document.observe(&#8220;dom:loaded&#8221;, function(){<br />
        for(var i = 0; i &lt; document.forms.length; i  ){<br />
            document.forms[i]._submit = document.forms[i].submit;<br />
            document.forms[i].submit  = fakeSubmit;<br />
        }<br />
    });<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JavaScript Event &#38; Event Method Bugs and Workarounds &#124; Brian Crescimanno</title>
		<link>http://briancrescimanno.com/2009/05/14/form-submit-method-doesnt-fire-submit-event-workaround/comment-page-1/#comment-316</link>
		<dc:creator>JavaScript Event &#38; Event Method Bugs and Workarounds &#124; Brian Crescimanno</dc:creator>
		<pubDate>Thu, 14 May 2009 20:33:11 +0000</pubDate>
		<guid isPermaLink="false">http://briancrescimanno.com/?p=57#comment-316</guid>
		<description>[...] Update 5/14/2009: By pure coincidence, I&#039;ve added to this post exactly 1 year to the day after I first wrote it. Please see a new post on a Workaround for form submit events not firing with the submit method. [...]</description>
		<content:encoded><![CDATA[<p>[...] Update 5/14/2009: By pure coincidence, I&#8217;ve added to this post exactly 1 year to the day after I first wrote it. Please see a new post on a Workaround for form submit events not firing with the submit method. [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
