<?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>Ryan Coughlin &#124; Web and Graphic Designer &#187; dynamic</title>
	<atom:link href="http://www.ryancoughlin.com/tag/dynamic/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ryancoughlin.com</link>
	<description></description>
	<lastBuildDate>Fri, 26 Mar 2010 00:07:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Working with the jQuery live function</title>
		<link>http://www.ryancoughlin.com/2009/05/04/working-with-the-jquery-live-function/</link>
		<comments>http://www.ryancoughlin.com/2009/05/04/working-with-the-jquery-live-function/#comments</comments>
		<pubDate>Mon, 04 May 2009 13:56:18 +0000</pubDate>
		<dc:creator>Ryan Coughlin</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[click]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[live]]></category>

		<guid isPermaLink="false">http://www.ryancoughlin.com/?p=450</guid>
		<description><![CDATA[Find out how to use jQuery .live() and how it compares with .click()


Related posts:<ol><li><a href='http://www.ryancoughlin.com/2009/01/22/jquery-timeout-function/' rel='bookmark' title='Permanent Link: jQuery Timeout Function'>jQuery Timeout Function</a> <small>A neat and simple way to creating a jQuery function...</small></li>
<li><a href='http://www.ryancoughlin.com/2009/03/30/create-a-jquery-accordion-remain-open-after-page-load/' rel='bookmark' title='Permanent Link: Create a jQuery Accordion &#8211; remain open after page load'>Create a jQuery Accordion &#8211; remain open after page load</a> <small>Quick fix to keep accordion section open after loading different...</small></li>
<li><a href='http://www.ryancoughlin.com/2008/11/23/combining-selectables-and-draggables-using-jquery-ui/' rel='bookmark' title='Permanent Link: Combining Selectables And Draggables Using jQuery UI'>Combining Selectables And Draggables Using jQuery UI</a> <small>Learn how to work with both selectable and draggable with...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The other day, I wasn&#8217;t really too acquainted with the .live() jQuery function. I did some research and it finally clicked for me. I put together a <a href="http://ryancoughlin.com/demos/live/jquery.live.html" target="_blank">quick example</a> that can I uploaded. The basics of the function can be known as:</p>
<blockquote><p>Binds a handler to an event (like click) for all current &#8211; and future &#8211; matched element.  Can also bind custom events. &#8211; (source: jquery.com)</p></blockquote>
<p>This function is extremely similar to the .click() but .click() will only match elements that are created via the XHTML with DOM is loaded. With that said, using .live() is extremely useful for dynamic websites, where you are creating/removing elements on you&#8217;re website.</p>
<p>Lets see the base example of using .live()</p>
<pre class="js" title="code">
$('a.edit').live('click', function() {
     alert("The power of .live() - dynamically created objects will have bound events!")
     return false;
});
</pre>
<p>This code will work for all links that have the class edit, even when new a.link tags are created dynamically after DOM has been loaded. If your code looked like:</p>
<pre class="js" title="code">
$('a.edit-nolive').click(function() {
     alert("Items created via AJAX will be called on using .live()")
     return false;
});</pre>
<p>It would not work on dynamically created items. Lets take another look at the <a href="http://ryancoughlin.com/demos/live/jquery.live.html" target="_blank">full demo</a>. Hopefully this will clear up any problems with understanding how the jQuery .live() function works in comparison to the .click() event. Like to see something else like this? Drop me a line.</p>


<p>Related posts:<ol><li><a href='http://www.ryancoughlin.com/2009/01/22/jquery-timeout-function/' rel='bookmark' title='Permanent Link: jQuery Timeout Function'>jQuery Timeout Function</a> <small>A neat and simple way to creating a jQuery function...</small></li>
<li><a href='http://www.ryancoughlin.com/2009/03/30/create-a-jquery-accordion-remain-open-after-page-load/' rel='bookmark' title='Permanent Link: Create a jQuery Accordion &#8211; remain open after page load'>Create a jQuery Accordion &#8211; remain open after page load</a> <small>Quick fix to keep accordion section open after loading different...</small></li>
<li><a href='http://www.ryancoughlin.com/2008/11/23/combining-selectables-and-draggables-using-jquery-ui/' rel='bookmark' title='Permanent Link: Combining Selectables And Draggables Using jQuery UI'>Combining Selectables And Draggables Using jQuery UI</a> <small>Learn how to work with both selectable and draggable with...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ryancoughlin.com/2009/05/04/working-with-the-jquery-live-function/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Create a jQuery Accordion &#8211; remain open after page load</title>
		<link>http://www.ryancoughlin.com/2009/03/30/create-a-jquery-accordion-remain-open-after-page-load/</link>
		<comments>http://www.ryancoughlin.com/2009/03/30/create-a-jquery-accordion-remain-open-after-page-load/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 19:28:50 +0000</pubDate>
		<dc:creator>Ryan Coughlin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[accordion]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.ryancoughlin.com/?p=411</guid>
		<description><![CDATA[Quick fix to keep accordion section open after loading different URL. Without any use of history plugins.


Related posts:<ol><li><a href='http://www.ryancoughlin.com/2009/05/04/working-with-the-jquery-live-function/' rel='bookmark' title='Permanent Link: Working with the jQuery live function'>Working with the jQuery live function</a> <small>Find out how to use jQuery .live() and how it...</small></li>
<li><a href='http://www.ryancoughlin.com/2009/05/06/how-to-load-data-using-jsonphp-using-jquery/' rel='bookmark' title='Permanent Link: How to load data using JSON/PHP using jQuery'>How to load data using JSON/PHP using jQuery</a> <small>I have seen a good amount of people wanting to...</small></li>
<li><a href='http://www.ryancoughlin.com/2008/11/23/combining-selectables-and-draggables-using-jquery-ui/' rel='bookmark' title='Permanent Link: Combining Selectables And Draggables Using jQuery UI'>Combining Selectables And Draggables Using jQuery UI</a> <small>Learn how to work with both selectable and draggable with...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I am currently working on this site for a client: http://www.hornedpout.com/ &#8211; a very basic portfolio website for a designer/writer. I didn&#8217;t want to use the bulky code of the jQuery UI so I decided to use the smaller version, below:</p>
<pre class="js" title="code">$(".menu-header").click(function() {
        $(this).next().toggle('slow');
        return false;
}).next().hide();</pre>
<p>The HTML would look something similar to:</p>
<pre class="html" title="code">
<h2 class="menu-header">art gallery</h2>
<ul>
<li class="item"><a title="Traditional Art Work" href="?c=traditional">traditional</a></li>
<li class="item"><a title="Digital" href="?c=digital">digital</a></li>
<li class="item"><a title="Posters" href="?c=posters">posters</a></li>
<li class="item"><a title="Icons" href="?c=icons">icons</a></li>
<li class="item"><a title="Fonts" href="?c=fonts">fonts</a></li>
</ul>
<h2 class="menu-header">verse</h2>
<ul>
<li><a title="Poems" href="?c=poems">Poems</a></li>
<li><a title="Stories" href="?c=stories">Stories</a></li>
</ul>
</pre>
<p>That code will use jQuery&#8217;s <strong>toggle()</strong> function. When the user clicks the <strong>h2</strong> tag it will close all elements until the next<br />
tag. This snippet is very handy for creating a quick accordion effect, this can also be found on the jQuery&#8217;s <a href="http://docs.jquery.com/UI/Accordion">documentation</a></p>
<p>Now we have the guts sorted out, but the problem is if you travel to another page within that category, it will close. I&#8217;m sure you want to check out the code that is going to do this.</p>
<p><strong>Keep that open!</strong></p>
<pre class="js" title="code">var matches;
     if( matches = (new String(document.location)).match(/?c=w+/) ) {
        $("a[href=" + matches[0] + "]").parents("ul").toggle();
     }</pre>
<p>The code above is fairly straight forward. The first line checks to see if we already have a sub-menu open. It evaluates by looking at the current pages URL <strong>&#8220;?c=page_here&#8221;</strong>.</p>
<p>The latter part of the code. Now that we grabbed the current URL of the sub-menu, we can use this to find the parent menu which is the<br />
<strong>ul</strong> and display it:</p>
<pre class="js" title="code">$("a[href=" + matches[0] + "]").parents("ul").toggle();</pre>
<p>The quick fix to keep your accordion block open while traveling to different URLS. To achieve the URLS of &#8220;?c=page&#8221;. I am using this PHP code below save it as index.php, also create a header.php and a footer.php.</p>
<p>Give it a shot, hope that this can work for you, it did wonders for my project. Also thanks to <a href="http://kent-fredric.fox.geek.nz/">Kent</a>, for helping me. If it did work post some examples!</p>


<p>Related posts:<ol><li><a href='http://www.ryancoughlin.com/2009/05/04/working-with-the-jquery-live-function/' rel='bookmark' title='Permanent Link: Working with the jQuery live function'>Working with the jQuery live function</a> <small>Find out how to use jQuery .live() and how it...</small></li>
<li><a href='http://www.ryancoughlin.com/2009/05/06/how-to-load-data-using-jsonphp-using-jquery/' rel='bookmark' title='Permanent Link: How to load data using JSON/PHP using jQuery'>How to load data using JSON/PHP using jQuery</a> <small>I have seen a good amount of people wanting to...</small></li>
<li><a href='http://www.ryancoughlin.com/2008/11/23/combining-selectables-and-draggables-using-jquery-ui/' rel='bookmark' title='Permanent Link: Combining Selectables And Draggables Using jQuery UI'>Combining Selectables And Draggables Using jQuery UI</a> <small>Learn how to work with both selectable and draggable with...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ryancoughlin.com/2009/03/30/create-a-jquery-accordion-remain-open-after-page-load/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
