<?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>tgreenaway.com &#187; jQuery</title>
	<atom:link href="http://tgreenaway.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://tgreenaway.com</link>
	<description>Creatively engineered.</description>
	<lastBuildDate>Sat, 30 May 2009 06:06:07 +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>Tripping up your JavaScript in IE7</title>
		<link>http://tgreenaway.com/2009/02/tripping-up-your-javascript-in-ie7/</link>
		<comments>http://tgreenaway.com/2009/02/tripping-up-your-javascript-in-ie7/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 03:08:47 +0000</pubDate>
		<dc:creator>TCMG</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tgreenaway.com/?p=254</guid>
		<description><![CDATA[After developing an intensive JavaScript website in Firefox and testing with other browsers, including IE8 in compatibility mode I discovered IE8&#8217;s compatibility mode doesn&#8217;t simulate IE7&#8217;s JS.
Hence a JS bug was bringing all of IE7&#8217;s JS processing to a halt even on the initial page load.
A first step I recommend is temporarily deactivating any JS [...]]]></description>
			<content:encoded><![CDATA[<p>After developing an intensive JavaScript website in Firefox and testing with other browsers, including IE8 in compatibility mode I discovered IE8&#8217;s compatibility mode doesn&#8217;t simulate IE7&#8217;s JS.</p>
<p>Hence a JS bug was bringing all of IE7&#8217;s JS processing to a halt even on the initial page load.</p>
<p>A first step I recommend is temporarily deactivating any JS compressors you may have enabled as pathing problems can crop up from using them and cause issues for IE7.</p>
<p>Beyond that I discovered the major snag resulted in this error from Visual Studio:</p>
<blockquote><p>Expected identifier, string or number</p></blockquote>
<p>Unfortunately that doesn&#8217;t give too much information but I was discovering it in my callback functions within my jQuery. It turns out IE7 has a particular issue with the syntax of JSON:</p>
<pre>
<pre class="brush: javascript;">
$(&quot;.box&quot;).animate({
    height: &quot;100%&quot;,
    opacity: &quot;1.0&quot;,
  }, 600, function() {
    alert(&quot;test!&quot;);
});
</pre>
</pre>
<p>While the above appears to be valid there is a deceptively simple issue that IE7 chokes on. The comma on the end of the third line. While most browsers recognise the empty slot after the opacity variable of the JSON array being passed into the animate function &#8211; IE7 gets really confused and starts complaining about the next semi-colon in your code (in this case part of the callback function).</p>
<p>Just an interesting issue that other browsers don&#8217;t care about but IE7 is really bamboozled by <img src='http://tgreenaway.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tgreenaway.com/2009/02/tripping-up-your-javascript-in-ie7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery list insertion sort plugin</title>
		<link>http://tgreenaway.com/2009/01/jquery-list-insertion-sort-plugin/</link>
		<comments>http://tgreenaway.com/2009/01/jquery-list-insertion-sort-plugin/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 00:56:42 +0000</pubDate>
		<dc:creator>TCMG</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tgreenaway.com/?p=221</guid>
		<description><![CDATA[Here&#8217;s a basic jQuery sorting plugin for generic parent child relationships I wrote.
Wherein &#8216;element&#8217; is the html you wish to insert and &#8216;value&#8217; is what the associated weight of the element I&#8217;m inserting. For now it compares the weight value to the DOM text within the other children.


$.fn.insertSort = function(element, value) {
  selector = [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a basic jQuery sorting plugin for generic parent child relationships I wrote.</p>
<p>Wherein &#8216;element&#8217; is the html you wish to insert and &#8216;value&#8217; is what the associated weight of the element I&#8217;m inserting. For now it compares the weight value to the DOM text within the other children.</p>
<pre>
<pre class="brush: jscript;">
$.fn.insertSort = function(element, value) {
  selector = this;
  if ($(selector).length &gt; 0) {
    $(selector).attr(&quot;inserted&quot;, &quot;false&quot;);
    $(selector).children().each(function() {
      if (parseInt($(this).text()) &gt; parseInt(value)) {
        $(this).before(element);
        $(selector).attr(&quot;inserted&quot;, &quot;true&quot;);
        return false;
      }
    });
    if ($(selector).attr(&quot;inserted&quot;) == &quot;false&quot;) {
      $(selector).append(element);
    }
  } else {
    $(selector).append(element);
  }
  $(selector).removeAttr(&quot;inserted&quot;);
};
</pre>
</pre>
<p>It should be noted that this is an <strong>insertion sort</strong>. It&#8217;d be good to extend the plugin to be able to sort an existing piece of html for any parent/child relationship. Possibly with the ability to specify a particular level of depth?</p>
]]></content:encoded>
			<wfw:commentRss>http://tgreenaway.com/2009/01/jquery-list-insertion-sort-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy checkbox toggling with jQuery</title>
		<link>http://tgreenaway.com/2009/01/easy-checkbox-toggling-with-jquery/</link>
		<comments>http://tgreenaway.com/2009/01/easy-checkbox-toggling-with-jquery/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 04:27:34 +0000</pubDate>
		<dc:creator>TCMG</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tgreenaway.com/?p=204</guid>
		<description><![CDATA[So I needed to have a regular form checkbox toggle the visibility of a div in my webpage today. It turned out jQuery supports the concept of toggling visibility via .toggle(), which I didn&#8217;t realise until I looked it up. And so you can support clicking or even keyboard changing of the checkbox via the [...]]]></description>
			<content:encoded><![CDATA[<p>So I needed to have a regular form checkbox toggle the visibility of a div in my webpage today. It turned out jQuery supports the concept of toggling visibility via .toggle(), which I didn&#8217;t realise until I looked it up. And so you can support clicking or even keyboard changing of the checkbox via the change event:</p>
<pre class="brush: jscript;">

$(&quot;#checkbox&quot;).change(function() {

$(&quot;#areaToToggle&quot;).toggle();

});
</pre>
<p>Pretty sweet, obviously the div should be hidden to begin with. We could add another line after the change event:</p>
<pre class="brush: jscript;">

$(&quot;#areaToToggle&quot;).hide();
</pre>
<p>Too easy <img src='http://tgreenaway.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tgreenaway.com/2009/01/easy-checkbox-toggling-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Context Menu Plugin</title>
		<link>http://tgreenaway.com/2008/11/jquery-context-menu-plugin/</link>
		<comments>http://tgreenaway.com/2008/11/jquery-context-menu-plugin/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 05:11:59 +0000</pubDate>
		<dc:creator>TCMG</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tgreenaway.com/?p=104</guid>
		<description><![CDATA[Okay, this jQuery plugin (by Cory S.N. LaViska) is awesome:

 Tutorial
 Demo


Basically you can achieve a right-click drop-down menu via the following jQuery code:

$(&#34;#selector&#34;).contextMenu({
menu: 'myMenu'
});

Where &#8216;myMenu&#8217; is the id of the HTML you want to appear as the menu:

&#60;ul id=&#34;myMenu&#34; class=&#34;contextMenu&#34;&#62;
&#60;li class=&#34;first_option&#34;&#62; &#60;a href=&#34;#first_option&#34;&#62;Option #1&#60;/a&#62;&#60;/li&#62;
&#60;li class=&#34;second_option&#34;&#62; &#60;a href=&#34;#second_option&#34;&#62;Option #2&#60;/a&#62;&#60;/li&#62;
&#60;/ul&#62;

I may need to use this in [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, this jQuery plugin (by Cory S.N. LaViska) is awesome:</p>
<ul>
<li><a href="http://abeautifulsite.net/notebook/80"> Tutorial</a><a href="http://"></a></li>
<li> <a href="http://abeautifulsite.net/notebook_files/80/demo/jqueryContextMenu.html">Demo</a><a href="http://"><br />
</a></li>
</ul>
<p>Basically you can achieve a right-click drop-down menu via the following jQuery code:</p>
<pre class="brush: jscript;">
$(&quot;#selector&quot;).contextMenu({
menu: 'myMenu'
});
</pre>
<p>Where &#8216;myMenu&#8217; is the id of the HTML you want to appear as the menu:</p>
<pre class="brush: html;">
&lt;ul id=&quot;myMenu&quot; class=&quot;contextMenu&quot;&gt;
&lt;li class=&quot;first_option&quot;&gt; &lt;a href=&quot;#first_option&quot;&gt;Option #1&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;second_option&quot;&gt; &lt;a href=&quot;#second_option&quot;&gt;Option #2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>I may need to use this in my next version of Chalk <img src='http://tgreenaway.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tgreenaway.com/2008/11/jquery-context-menu-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging Javascript</title>
		<link>http://tgreenaway.com/2008/08/debugging-javascript/</link>
		<comments>http://tgreenaway.com/2008/08/debugging-javascript/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 15:39:08 +0000</pubDate>
		<dc:creator>TCMG</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tgreenaway.com/?p=49</guid>
		<description><![CDATA[So far my experience with Javascript has not required too much dealing with its raw form. I&#8217;m a big fan of the jQuery library and I&#8217;ve heard described as a swiss army knife for Javascript. I think that&#8217;s an understatement though, it goes beyond just being a toolset. I believe it is a framework in [...]]]></description>
			<content:encoded><![CDATA[<p>So far my experience with Javascript has not required too much dealing with its raw form. I&#8217;m a big fan of the jQuery library and I&#8217;ve heard described as a swiss army knife for Javascript. I think that&#8217;s an understatement though, it goes beyond just being a toolset. I believe it is a framework in its own right. And in fact, it pushes all your Javascript code into a more structured form.</p>
<p>I recently fixed a problem with a website that was developed by someone using raw Javascript. Basically it failed to work in IE. The underlying problem was that IE doesn&#8217;t recognise the visual text of a drop down select box in the DOM of the page as the &#8216;value&#8217; of the element in the drop down select box.</p>
<p>So if you selected &#8220;5pm&#8221; from the box, the Javascript can&#8217;t be:</p>
<pre>
<pre class="brush: jscript;">foo = frm.select[bar].value;</pre>
</pre>
<p>It has to be:</p>
<pre>
<pre class="brush: jscript;">foo = frm.select[bar].text;</pre>
</pre>
<p>If you want it to work across all the browsers. In jQuery, you would never even write code like the above. You&#8217;d be using the CSS selectors:</p>
<pre>
<pre class="brush: jscript;">$(&quot;#date_select&quot;).text();</pre>
</pre>
<p>The above would find the element with id &#8216;date_select&#8217; and extract its text. Why the dollar sign? It tells Javascript we&#8217;re dealing with the jQuery library.</p>
<p>So you see, jQuery just <em>looks </em>different to raw Javascript most of the time. For example, take a load of this raw Javascript:</p>
<pre>
<pre class="brush: jscript;">
document.getElementById(&amp;quot;x20&amp;quot;).style.display='none';
document.getElementById(&amp;quot;x21&amp;quot;).style.display='none';
document.getElementById(&amp;quot;x22&amp;quot;).style.display='none';

var d = frm.Dates;
var dval = d.options[d.selectedIndex].text;
var idx;

for (x=frm.Times.length;x&amp;gt;0;x=x-1)
{
        frm.Times.remove(x);
}
</pre>
</pre>
<p>Ugh, messy. jQuery steps away from the &#8216;document&#8217; rubbish by using the CSS selectors mentioned previously. And the for loop? jQuery provides you with functions to iterate throughout CSS selected elements:</p>
<pre>
<pre class="brush: jscript;">
$(&quot;#times_list li&quot;).each(function () {
  this.remove()
}
</pre>
</pre>
<p>Where &#8216;this&#8217; is one of the CSS selector&#8217;s matched elements, iterated by the &#8216;each&#8217; function.</p>
]]></content:encoded>
			<wfw:commentRss>http://tgreenaway.com/2008/08/debugging-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
