<?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>David Little</title>
	<atom:link href="http://www.littled.net/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.littled.net</link>
	<description>User interface designer</description>
	<lastBuildDate>Sun, 22 Jan 2012 17:21:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>How to close a jQuery dialog box by clicking outside of it</title>
		<link>http://www.littled.net/2009/11/30/how-to-close-a-jquery-dialog-box-by-clicking-outside-of-it/</link>
		<comments>http://www.littled.net/2009/11/30/how-to-close-a-jquery-dialog-box-by-clicking-outside-of-it/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 15:34:58 +0000</pubDate>
		<dc:creator>wdavid</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://www.littled.net/new/?p=392</guid>
		<description><![CDATA[JQuery gives you a very simple way to create dialog overlays with the dialog() event. So, by clicking an HTML element you can activate a &#8220;stay-on-the-page&#8221; overlay dialog box. Traditionally one might use dialog boxes to ask the user a &#8230; <a href="http://www.littled.net/2009/11/30/how-to-close-a-jquery-dialog-box-by-clicking-outside-of-it/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>JQuery gives you a very simple way to <a href="http://docs.jquery.com/UI/Dialog">create dialog overlays</a> with the dialog() event. So, by clicking an HTML element you can activate a &#8220;stay-on-the-page&#8221; overlay dialog box.</p>
<p>Traditionally one might use dialog boxes to ask the user a question to which she must respond (e.g. with an &#8220;Ok&#8221; or &#8220;Cancel&#8221;) but their use can extend beyond this. For instance I&#8217;ve used a dialog to show a <a href="http://www.useit.com/alertbox/mega-dropdown-menus.html">mega drop-down menu</a>; i.e. clicking a link opens a dialog box with a list of categorised links.</p>
<p>JQuery&#8217;s default behaviour for closing dialog boxes is not unreasonable: the user must click on the &#8220;Close&#8221; button (e.g. in the form of text or an &#8220;x&#8221;) or hit the escape key. However it&#8217;s possible you may want to provide more options for your users to close a box by simply clicking outside it.</p>
<p>I puzzled over this and didn&#8217;t get very far with Googling but came up with the following solution which seems to work.</p>
<p>When your dialog is created, a div with the class &#8220;ui-widget-overlay&#8221; is also created which &#8220;greys out&#8221; the background allowing the user to fully focus on the dialog. You can use this as a hook to add your dialog closing code, e.g.</p>
<p><code><br />
$(".ui-widget-overlay").live("click", function() {  $("#quick-links-modal").dialog("close"); } );<br />
</code></p>
<p>In this case my dialog has the ID &#8220;quick-links-modal&#8221;. NB you need to use the &#8220;live&#8221; event (rather than &#8220;click&#8221; etc.)  in order to bind the event to your dialog before the dialog has been initiated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littled.net/2009/11/30/how-to-close-a-jquery-dialog-box-by-clicking-outside-of-it/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

