<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>t+1 &#187; jQuery</title>
	<atom:link href="http://blog.tplus1.com/index.php/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tplus1.com</link>
	<description>Programming, gardening, economics, life in Cleveland Heights</description>
	<lastBuildDate>Sat, 07 Jan 2012 21:12:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Approaching jQuery popup callback hell</title>
		<link>http://blog.tplus1.com/index.php/2009/08/31/approaching-popup-callback-hell/</link>
		<comments>http://blog.tplus1.com/index.php/2009/08/31/approaching-popup-callback-hell/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 18:00:08 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.tplus1.com/?p=421</guid>
		<description><![CDATA[I wrote this post on the jQuery mailing list and nobody replied, so I&#8217;m pasting it here.  I could really use some advice.
I&#8217;m using a modal dialogs and I love them, but I haven&#8217;t found a really elegant way to handle actions in the dialog window that require changes to the parent page.
Here&#8217;s an [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote <a href="http://groups.google.com/group/jquery-en/browse_thread/thread/7164408eff0ac141/68123bfe5549dadc#68123bfe5549dadc">this post</a> on the jQuery mailing list and nobody replied, so I&#8217;m pasting it here.  I could really use some advice.</p>
<p>I&#8217;m using a modal dialogs and I love them, but I haven&#8217;t found a really elegant way to handle actions in the dialog window that require changes to the parent page.</p>
<p>Here&#8217;s an example.  I have a monthly calendar page that lists employee names on the days they are supposed to work.  Clicking on an employee name opens a &#8220;shift detail&#8221; page in a modal dialog.</p>
<p>That shift detail page has more information like the specific tasks planned for the day, the start time and stop time of the shift, etc.  From this shift detail screen, I can remove this particular employee from the schedule by submitting an AJAX POST from this popup.</p>
<p>After I remove the employee, I need to update both the popup window and the original page that hosted the link to the popup window.  Right now I do this by adding a callback that fires when the AJAX POST succeeds.  That callback then updates both pages.  The callback is named &#8220;after_remove_employee&#8221;.</p>
<p>This system gets really nasty when I use the &#8220;shift detail&#8221; popup on different screens.  For example, in addition to the monthly view, I also have a weekly view with more information.  So after an employee is removed from the schedule on the weekly view, I need to do some different things in the callback.</p>
<p>Right now, the way I handle this is that I define the same callback twice.  I define &#8220;var after_remove_employee = function (data) {&#8230;} on the weekly view to do what it needs there, and then I define it differently on the monthly view.</p>
<p>I&#8217;ve simplified the problem to help explain it.  In reality, I have lots of different popups on lots of different pages, and in each popup, there are many different possible actions.</p>
<p>I&#8217;m sure I&#8217;m not the only one that&#8217;s been in this scenario.  What is an elegant solution?</p>
<p>I&#8217;m thinking about using custom events.  So, the callback after a successful AJAX POST would just fire an &#8220;employee removed&#8221; event, and everybody subscribed would get a reference to the event object and do whatever they want.</p>
<p>However, I&#8217;ve never used JS events before, and I don&#8217;t know if this is even possible.</p>
<p>Please, any feedback is welcome. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tplus1.com/index.php/2009/08/31/approaching-popup-callback-hell/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>jQuery for the win</title>
		<link>http://blog.tplus1.com/index.php/2008/03/07/jquery-for-the-win/</link>
		<comments>http://blog.tplus1.com/index.php/2008/03/07/jquery-for-the-win/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 18:40:42 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.tplus1.com/index.php/2008/03/07/jquery-for-the-win/</guid>
		<description><![CDATA[I needed to toggle some text between &#8220;show help&#8221; and &#8220;hide help&#8221;.
First, I wrote this and thought I was good:
&#60;style type=&#34;text/css&#34;&#62;
span.hide { display:none }
&#60;/style&#62;
&#60;script type=&#34;text/javascript&#34;&#62;
$(document).ready(function () {
&#160;&#160;&#160;&#160;$(&#34;a.showhide&#34;).click(function (event) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$(&#34;span.show&#34;).toggle();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$(&#34;span.hide&#34;).toggle();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return false;
&#160;&#160;&#160;&#160;})
});
&#60;/script&#62;
&#60;a class=&#34;showhide&#34;&#62;&#60;span class=&#34;show&#34;&#62;Show Help&#60;/span&#62;&#60;span class=&#34;hide&#34;&#62;Hide Help&#60;/span&#62;&#60;/a&#62;

That flips the text from &#8220;Show Help&#8221; to &#8220;Hide Help&#8221;.  But the code can be made even shorter by calling [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to toggle some text between &#8220;show help&#8221; and &#8220;hide help&#8221;.</p>
<p>First, I wrote this and thought I was good:</p>
<p><pre><code>&lt;style type=&quot;text/css&quot;&gt;
span.hide { display:none }
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function () {
&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;a.showhide&quot;).click(function (event) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;span.show&quot;).toggle();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;span.hide&quot;).toggle();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;
&nbsp;&nbsp;&nbsp;&nbsp;})
});
&lt;/script&gt;
&lt;a class=&quot;showhide&quot;&gt;&lt;span class=&quot;show&quot;&gt;Show Help&lt;/span&gt;&lt;span class=&quot;hide&quot;&gt;Hide Help&lt;/span&gt;&lt;/a&gt;
</code></pre></p>
<p>That flips the text from &#8220;Show Help&#8221; to &#8220;Hide Help&#8221;.  But the code can be made even shorter by calling toggle on both spans at once:</p>
<p><pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function () {
&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;a.showhide&quot;).click(function (event) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;a.showhide span&quot;).toggle();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;
&nbsp;&nbsp;&nbsp;&nbsp;})
});
&lt;/script&gt;
</code></pre></p>
<p>I heart jQuery.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tplus1.com/index.php/2008/03/07/jquery-for-the-win/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

