<?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>Winn.ws &#187; Javascript</title>
	<atom:link href="http://winn.ws/archives/tag/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://winn.ws</link>
	<description>Standards-based design &#38; development</description>
	<lastBuildDate>Thu, 09 Sep 2010 14:05:05 +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>.live() and the future</title>
		<link>http://winn.ws/archives/343</link>
		<comments>http://winn.ws/archives/343#comments</comments>
		<pubDate>Sun, 18 Apr 2010 06:25:40 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.winn.ws/?p=343</guid>
		<description><![CDATA[Just recently i seen this used by a co-worker, and did not know much about this. So I took some time and looked it up on the jQuery site docs. I was amazed by what it does, the .live() function will match any element now and in the future! This means if you .load() a [...]]]></description>
			<content:encoded><![CDATA[<p>Just recently i seen this used by a co-worker, and did not know much about this. So I took some time and looked it up on the jQuery site docs. I was amazed by what it does, the .live() function will match any element now and in the future! This means if you .load() a remote page in the .live() can match an element on that page as it&#8217;s loaded in!</p>
<blockquote><p>Attach a handler to the event for all elements which match the current selector, now or in the future. <a href="http://api.jquery.com/live/">jQuery &#8211; .live()</a></p></blockquote>
<p><strong>Some info on .live()</strong><br />
his method is a variation on the basic .bind() method for attaching event handlers to elements. When .bind() is called, the elements that the jQuery object refers to get the handler attached; elements that get introduced later do not, so they would require another .bind() call. For instance, consider the HTML:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;body&gt;
  &lt;div class=&quot;clickme&quot;&gt;
    Click here
  &lt;/div&gt;
&lt;/body&gt;</pre></div></div>

<p>We can bind a simple click handler to this element:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.clickme'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// Bound handler called.</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>When the element is clicked, the handler is called. However, suppose that after this, another element is added:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div class=&quot;clickme&quot;&gt;Another target&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This new element also matches the selector .clickme, but since it was added after the call to .bind(), clicks on it will do nothing.</p>
<p>The .live() method provides an alternative to this behavior. If we bind a click handler to the target element using this method:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.clickme'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// Live handler called.</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And then later add a new element:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div class=&quot;clickme&quot;&gt;Another target&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Then clicks on the new element will also trigger the handler.</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/343/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cookies with JQuery</title>
		<link>http://winn.ws/archives/196</link>
		<comments>http://winn.ws/archives/196#comments</comments>
		<pubDate>Tue, 10 Feb 2009 05:16:32 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.winn.ws/?p=196</guid>
		<description><![CDATA[So in some of my latest projects i dont have full source access, so i need to look for cookies the main application is setting. To do this i am using jQuery to look into the cookies and give me the value. Once i know the value i can then write a new cookie that [...]]]></description>
			<content:encoded><![CDATA[<p>So in some of my latest projects i dont have full source access, so i need to look for cookies the main application is setting. To do this i am using jQuery to look into the cookies and give me the value. Once i know the value i can then write a new cookie that the main application will see and use.</p>
<p>Below is an idea of what i am doing to read the cookies from the main application.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">cookie</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Cookie_name'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #003366; font-weight: bold;">var</span> MainAppCookie <span style="color: #339933;">=</span> $.<span style="color: #660066;">cookie</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Cookie_name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     $.<span style="color: #660066;">cookie</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'NewCookie_'</span> <span style="color: #339933;">+</span> MainAppCookie <span style="color: #339933;">,</span> <span style="color: #3366CC;">'Value'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>To use the $.cookie i am using a simple plugin for jQuery. This allows me to access the cookies quick and easy. Now if the application gives me a special cookie i can then delete my old ones by doing this&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">cookie</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Cookie_name'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'Special Text'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     $.<span style="color: #660066;">cookie</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyCookie'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// This will delete the cookie</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/196/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The OO way of JavaScript</title>
		<link>http://winn.ws/archives/174</link>
		<comments>http://winn.ws/archives/174#comments</comments>
		<pubDate>Tue, 28 Oct 2008 15:00:51 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[web standards]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.winn.ws/?p=174</guid>
		<description><![CDATA[This is something I picked up in making my own functions and trying not to effect my other js libraries. I first start by creating a base function like so:

function Wrapper() {
&#160;
}

Then inside that function I create my “methods” if you will&#8230;

function Wrapper() {
     this.MyMethod = function(var) {
    [...]]]></description>
			<content:encoded><![CDATA[<p>This is something I picked up in making my own functions and trying not to effect my other js libraries. I first start by creating a base function like so:</p>

<div class="wp_syntax"><div class="code"><pre class="js" style="font-family:monospace;">function Wrapper() {
&nbsp;
}</pre></div></div>

<p>Then inside that function I create my “methods” if you will&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="js" style="font-family:monospace;">function Wrapper() {
     this.MyMethod = function(var) {
          return var;
     }
}</pre></div></div>

<p>Once I am done creating the methods I now need to call my new javascript methods, I can do this by creating a new instance of my function that wraps the methods.</p>

<div class="wp_syntax"><div class="code"><pre class="js" style="font-family:monospace;">var MyScript = new Wrapper();</pre></div></div>

<p>After creating the new instance I can now call my methods.</p>

<div class="wp_syntax"><div class="code"><pre class="js" style="font-family:monospace;">MyScript.MyMethod('Some Text');</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/174/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 2/10 queries in 0.002 seconds using memcached
Content Delivery Network via Amazon Web Services: CloudFront: dhbbuddo7esu2.cloudfront.net

Served from: winn.ws @ 2010-09-09 22:30:14 -->