<?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>Dan Appleyard &#187; jQuery</title>
	<atom:link href="http://www.danappleyard.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danappleyard.com</link>
	<description>Developer&#039;s Thoughts on Tech, Life, &#38; Stuff</description>
	<lastBuildDate>Thu, 21 Jul 2011 21:43:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Budapest Table Sorting Plugin</title>
		<link>http://www.danappleyard.com/2011/06/18/budapest-table-sorting-plugin/</link>
		<comments>http://www.danappleyard.com/2011/06/18/budapest-table-sorting-plugin/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 13:35:36 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://www.danappleyard.com/?p=645</guid>
		<description><![CDATA[Budapest is a jQuery plugin that allows for simple table sorting. It allows the developer to have full control over the sorting. Basic usage: $&#40;&#34;table&#34;&#41;.budapest&#40;&#41;; Advanced usage: $&#40;&#34;table&#34;&#41;.budapest&#40;&#123; headers: &#123; 0: &#123; sortable: true&#125;, 1: &#123; sortable: true&#125;, 2: &#123; sortable: true&#125; &#125;, sortIndex: 2, sortDirection: &#34;asc&#34;, onSort: function&#40;index, val1, val2, direction&#41;&#123; //provide your own [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.danappleyard.com/budapest/">Budapest</a> is a jQuery plugin that allows for simple table sorting. It allows the developer to have full control over the sorting.</p>
<h3>Basic usage:</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;table&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">budapest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Advanced usage:</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;table&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">budapest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
  headers<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #CC0000;">0</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #CC0000;">1</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #CC0000;">2</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  sortIndex<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span>
  sortDirection<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;asc&quot;</span><span style="color: #339933;">,</span>
  onSort<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> val1<span style="color: #339933;">,</span> val2<span style="color: #339933;">,</span> direction<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">//provide your own sorting algorithm for each column!</span>
    <span style="color: #006600; font-style: italic;">//must return either -1, 0, or 1</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  onSorted<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> direction<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">//this event is fired after each sort!</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a href="http://www.danappleyard.com/budapest/">Check out the full documentation.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danappleyard.com/2011/06/18/budapest-table-sorting-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No AJAX request in IE7</title>
		<link>http://www.danappleyard.com/2010/09/13/no-ajax-request-in-ie7/</link>
		<comments>http://www.danappleyard.com/2010/09/13/no-ajax-request-in-ie7/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 17:14:59 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.danappleyard.com/?p=423</guid>
		<description><![CDATA[I was recently trying to solve an issue regarding jquery and a ASP.NET Webforms application.  I would sometimes get an AJAX call to execute and other times it would not fire.  I was beating my brain into a bloody mush, when I discovered that it was skipping the AJAX request only in IE7 browsers.  IIIIIEEEEEEEEEEEEEEEEEEEEEE! [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://danappleyard.files.wordpress.com/2010/09/kahn1.png"><img class="aligncenter size-full wp-image-426" title="KAAAAAAAHHHHHNNNNN!" src="http://danappleyard.files.wordpress.com/2010/09/kahn1.png" alt="" width="536" height="303" /></a>I was recently trying to solve an issue regarding jquery and a ASP.NET Webforms application.  I would sometimes get an AJAX call to execute and other times it would not fire.  I was beating my brain into a bloody mush, when I discovered that it was skipping the AJAX request only in IE7 browsers.  <a href="http://www.youtube.com/watch?v=wRnSnfiUI54" target="_blank">IIIIIEEEEEEEEEEEEEEEEEEEEEE!</a></p>
<p>Thankfully, after regaining my composure, I was able to find a the solution right <a href="http://www.thushanfernando.com/index.php/2009/10/27/quickfix-jquery-getjson-fails-in-ie6-ie7/" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danappleyard.com/2010/09/13/no-ajax-request-in-ie7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The numbers don&#8217;t lie</title>
		<link>http://www.danappleyard.com/2010/05/20/the-numbers-dont-lie/</link>
		<comments>http://www.danappleyard.com/2010/05/20/the-numbers-dont-lie/#comments</comments>
		<pubDate>Thu, 20 May 2010 17:15:50 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[web forms]]></category>

		<guid isPermaLink="false">http://www.danappleyard.com/?p=125</guid>
		<description><![CDATA[Yesterday I talked about my hatred of postbacks and third party controls. Looking back on it, I didn&#8217;t include any numbers to back me up. Well, here are some numbers. In this scenario, I have a page that contains two dropdown controls. One is populated with the numbers one through 10. The second one is [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="http://www.americanprogress.org/cartoons/2009/04/img/040109.jpg" title="Numbers don&#039;t lie" class="aligncenter" width="288" height="320" /><br />
Yesterday I talked about my hatred of postbacks and third party controls.  Looking back on it, I didn&#8217;t include any numbers to back me up.  Well, here are some numbers.  In this scenario, I have a page that contains two dropdown controls.  One is populated with the numbers one through 10.  The second one is empty.  The goals is to populate the second dropdown when a selection is made on the first dropdown.  The first way we are going to implement this is through the typical postback method.</p>
<h2>Full Page Postback</h2>
<p>When an end user selects an item in the first dropdown, the browser will postback the entire page and code on the server will populate the second dropdown with data and send the updated html markup back to the browser to render again.  When there is just a small portion of the page that needs to be updated (as is the case in our example), that can be quite expensive!  In this example, I have various javascript, css, and image files that have to be downloaded from the server to the client on every load of the back.</p>
<h3>Server-side VB.Net Code</h3>
<pre class="brush:vb">
'this method is executed when the page posts back after a selection is made in the first dropdown
Private Sub drp1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles drp1.SelectedIndexChanged
        Dim letters As New List(Of String)
        letters.Add("A")
        letters.Add("B")
        letters.Add("C")
        letters.Add("D")
        letters.Add("E")
        letters.Add("F")
        letters.Add("G")
        letters.Add("H")
        letters.Add("I")
        letters.Add("J")
        letters.Add("K")
        letters.Add("L")
        letters.Add("M")
        letters.Add("N")
        letters.Add("O")
        letters.Add("P")
        letters.Add("Q")
        letters.Add("R")
        letters.Add("S")
        letters.Add("T")
        letters.Add("U")
        letters.Add("V")
        letters.Add("W")
        letters.Add("X")
        letters.Add("Y")
        letters.Add("Z")

        drp2.DataSource = letters
        drp2.DataBind()
    End Sub
</pre>
<h3>The Server-side Numbers</h3>
<p>When running this, we get a total of 218,049 bytes being sent from the server back to the browser.  This number includes the actual html of the entire page, and any necessary javascript, css, or image files that are needed on the page.  That is a lot of data!</p>
<h2>Ajax Post</h2>
<p>When an end user selects an item in the first dropdown, a javascript handler will call the server with a request for data to populate the second dropdown.  The server gets the request and sends back just the data requested.  The browser gets that data and puts it in the second dropdown.  There is no page refreshing.  There is no html, javascript, css, or image files being sent back to the client, because they are already there.  It is very light!</p>
<h3>jQuery Code</h3>
<pre class="brush:javascript">

        $(document).ready(function() {
            $("#").change(function() {
               //when a selection is made in the dropdown
              //do an ajax post back to the page and get a list of strings
                $.ajax({
                    type: "POST",
                    url: "WebForm1.aspx/GetNextCombobox",
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(msg) {
                       //we convert it into an array
                        var arr = jQuery.makeArray(msg.d);
                        //we find the dropdown we want to populate with data
                        var dd = $("#");
                        //let us empty it first of any existing data
                        dd.empty();
                        $.each(arr, function(i, v) {
                            //for each item in the array we got from the server, place it into the dropdown
                            dd.append($("").val(v).text(v));
                        });
                    }
                });
            });
        });
</pre>
<h3>Server-side VB.Net Code</h3>
<p>I am still trying out different syntax highlighters for my blog.  This one is sometimes adding extra tags when not needed.  Please excuse my malformed webmethod tag(s).</p>
<pre class="brush:vb">
'this method is executed when the javascript ajax call requests the data for the second dropdown
 _
Public Shared Function GetNextCombobox() as List(Of String)
        Dim letters As New List(Of String)
        letters.Add("A")
        letters.Add("B")
        letters.Add("C")
        letters.Add("D")
        letters.Add("E")
        letters.Add("F")
        letters.Add("G")
        letters.Add("H")
        letters.Add("I")
        letters.Add("J")
        letters.Add("K")
        letters.Add("L")
        letters.Add("M")
        letters.Add("N")
        letters.Add("O")
        letters.Add("P")
        letters.Add("Q")
        letters.Add("R")
        letters.Add("S")
        letters.Add("T")
        letters.Add("U")
        letters.Add("V")
        letters.Add("W")
        letters.Add("X")
        letters.Add("Y")
        letters.Add("Z")

        Return letters
    End Function
</pre>
<h3>The Ajax Numbers</h3>
<p>With this implementation, the server is only passing 111 bytes of data back.</p>
<h2>Recap</h2>
<p>The postback implementation cost us 218,049 bytes of data being sent from the server to the browser, while the jQuery implementation cost us only 111 bytes!  That is 1,964 times less data.  Why anyone would be fine with dealing with 1964 times of overhead is beyond me, but the numbers don&#8217;t lie.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danappleyard.com/2010/05/20/the-numbers-dont-lie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Devil and his minions: ASP.Net webforms and 3rd party web toolkits</title>
		<link>http://www.danappleyard.com/2010/05/19/the-devil-and-his-minions-asp-net-webforms-and-3rd-party-web-toolkits/</link>
		<comments>http://www.danappleyard.com/2010/05/19/the-devil-and-his-minions-asp-net-webforms-and-3rd-party-web-toolkits/#comments</comments>
		<pubDate>Thu, 20 May 2010 04:13:36 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Telerik]]></category>
		<category><![CDATA[web forms]]></category>

		<guid isPermaLink="false">http://www.danappleyard.com/?p=111</guid>
		<description><![CDATA[I am what you would call anal. Anal for total control over performance in my applications. I want to wring out as much performance as I possibly can. The web forms engine from Microsoft for their ASP.NET framework stop me from doing that. Web forms are bad for two reasons (I am sure there are [...]]]></description>
			<content:encoded><![CDATA[<p>I am what you would call anal.  Anal for total control over performance in my applications.  I want to wring out as much performance as I possibly can.  The web forms engine from Microsoft for their ASP.NET framework stop me from doing that.  Web forms are bad for two reasons (I am sure there are more, but I will just talk about two) &#8211; 1) Developers do not have full control over what the end result of the page is, and 2) postbacks.  Let me focus on postbacks today (I will talk about the rendering control at a later time).  With the ASP.NET web forms engine, postbacks are a regular occurence in the user experience.  If you go around on your favorite web site, and click a button and it refreshes the page, that is a postback.  Postbacks are a necessary thing for web applications, but no where the amount that web forms give us.</p>
<p>This is where 3rd party controls typically come in.  They usually offer Ajax capabilities that streamline the user experience by hiding the postback a page may execute.  With most Ajax calls generated by 3rd party controls, they go through the whole life cycle of the page, the rendering of the page is just localized to the section of the page that you as an end user interacted with.  Now some would say that the full page postback is a necessary evil for rapid development.  I disagree.  3rd party controls act as a black box for developers.  We know what the end result is, but we rarely investigate what is actually going on to make these controls act as they do.  I am on the side of taking the time to do it all manually.  Screw the controls!  I would rather take the time to do it myself, and have complete control of the implementation with the ability to change it if need be.  It strengthens you as a developer.</p>
<p><a href="http://jquery.com/">Enter jQuery.</a>  I absolutely love jQuery.  For those not familar with jQuery, it is a lightweight javascript library that has taken the web 2.0 world by storm.  There may be those of you that are saying to yourself &#8220;But Dan, isn&#8217;t that just another 3rd party toolkit?&#8221;  Well yes and no.  Yes it is something that I did not create, but it is completely extendable and the source code is available for viewing!  I really like that.  Also, with jQuery the concept of postbacks go away.  I have another motto &#8211; a page in a web application should only render once.  Anything else should be Ajax calls and plain old javascript.  Now if only I could convince my bosses to go to <a href="http://www.asp.net/mvc">ASP.NET MVC</a> (but that is another post for another day).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danappleyard.com/2010/05/19/the-devil-and-his-minions-asp-net-webforms-and-3rd-party-web-toolkits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

