<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devlicio.us/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Jak Charlton - Insane World : JQuery</title><link>http://devlicio.us/blogs/casey/archive/tags/JQuery/default.aspx</link><description>Tags: JQuery</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>ASP.NET MVC in the Wild</title><link>http://devlicio.us/blogs/casey/archive/2010/02/09/asp-net-mvc-in-the-wild.aspx</link><pubDate>Tue, 09 Feb 2010 11:02:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:55322</guid><dc:creator>Jak Charlton</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/casey/rsscomments.aspx?PostID=55322</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/casey/commentapi.aspx?PostID=55322</wfw:comment><comments>http://devlicio.us/blogs/casey/archive/2010/02/09/asp-net-mvc-in-the-wild.aspx#comments</comments><description>&lt;p&gt;Just before I emigrated to Australia, I took on a small contract to build a website for a UK company who wanted to start up a new kind of UK recruitment site, one where employers could advertise directly, and more specifically one where recruitment agencies couldn&amp;rsquo;t.&lt;/p&gt;
&lt;p&gt;The result was Empty Lemon (&lt;a href="http://www.emptylemon.co.uk"&gt;www.emptylemon.co.uk&lt;/a&gt;) &amp;ndash; I leave you to figure out why it is called Empty Lemon, took me a fair while to be honest!&lt;/p&gt;
&lt;p&gt;This site was built in around 4 weeks, using ASP.NET MVC2, NHibernate, Fluent NHibernate, Windsor, JQuery, Automapper, and a host of other great tools and libraries.&lt;/p&gt;
&lt;p&gt;The site is actually, despite the occasional bit of code I&amp;rsquo;m not too delighted with, a great example of how fast a site can be developed with ASP.NET MVC and the chosen tooling. In just four weeks we went from more or less nothing, to a full domain model (all be it a fairly simple one) running over a SQL Server 2008 database, using a combination of NH, Fulltext search and the Spatial services from SQL Server 2008.&lt;/p&gt;
&lt;p&gt;I also want to thank James Gregory, Steve Strong and Hadi Hariri for (sometimes unknowingly) helping me write the site, with useful snippets of code, and even in Steve&amp;rsquo;s case a lot of work on getting NH to play fair with the spatial services.&lt;/p&gt;
&lt;p&gt;So, if you are looking for a job in the UK, or if you are looking to employ someone, I strongly suggest you take a look at &lt;a href="http://www.emptylemon.co.uk"&gt;www.emptylemon.co.uk&lt;/a&gt;. It&amp;rsquo;s a little empty right now, but some large employers are coming on board soon, and other companies are signing up day by day &amp;ndash; these things are always chicken and egg, so if you like the site, feel free to tell others about it &amp;ndash; after all, who really likes recruitment agents anyway ;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=55322" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/casey/archive/tags/.NET/default.aspx">.NET</category><category domain="http://devlicio.us/blogs/casey/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://devlicio.us/blogs/casey/archive/tags/JQuery/default.aspx">JQuery</category><category domain="http://devlicio.us/blogs/casey/archive/tags/Castle/default.aspx">Castle</category><category domain="http://devlicio.us/blogs/casey/archive/tags/NHibernate/default.aspx">NHibernate</category></item><item><title>jQuery Gotcha - Functions in Events</title><link>http://devlicio.us/blogs/casey/archive/2008/10/09/jquery-gotcha-functions-in-events.aspx</link><pubDate>Thu, 09 Oct 2008 10:43:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:42615</guid><dc:creator>Jak Charlton</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/casey/rsscomments.aspx?PostID=42615</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/casey/commentapi.aspx?PostID=42615</wfw:comment><comments>http://devlicio.us/blogs/casey/archive/2008/10/09/jquery-gotcha-functions-in-events.aspx#comments</comments><description>&lt;p&gt;I just spent way too long wondering why my silly page kept refreshing itself, one of the forms on the page was submitting itself over and over ... I had been refactoring some Javascipt to allow me to use it generically across pages.&lt;/p&gt;
&lt;p&gt;My orginal code to bind an ajax call to the submit of the form was as follows:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;$(&amp;quot;#SearchForm&amp;quot;).submit(function() { ... previous ajax code inline here&amp;nbsp;...&amp;nbsp;; return false; });&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;And all was fine ... except I wanted to reuse the inline code, so I put it into a function:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;$(&amp;quot;#SearchForm&amp;quot;).submit(GetTableContent(controller, displaySelect));&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;And suddenly the page started refreshing automatically, making debugging it rather hard to even find the mistake. After 20 mins scanning through the &lt;a class="" href="http://docs.jquery.com/Events/submit#fn"&gt;jQuery documentation on form submit&lt;/a&gt; I noticed that &amp;quot;submit()&amp;quot; reads &amp;quot;Trigger the submit event of each matched element&amp;quot; but that &amp;quot;submit(fn)&amp;quot; reads &amp;quot;Bind a function to the submit event of each matched element&amp;quot; ... clearly the first version was being used by jQuery, where as my code should have been the second one - after all I had a function in there now?&lt;/p&gt;
&lt;p&gt;Then I twigged it, the jQuery (fn) wants a plain basic function with no parameters ... so a quick change wrap my new function with a parameterless function resolved the problem:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;$(&amp;quot;#SearchForm&amp;quot;).submit(function() { GetTableContent(controller, displaySelect); return false; });&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Annoying ... I hate wasting 20 mins on silly things like this ... &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=42615" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/casey/archive/tags/JQuery/default.aspx">JQuery</category></item><item><title>ASP.NET MVC, JQuery and Cross-View Javascript Events</title><link>http://devlicio.us/blogs/casey/archive/2008/09/17/asp-net-mvc-jquery-and-cross-view-javascript-events.aspx</link><pubDate>Wed, 17 Sep 2008 12:50:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:42334</guid><dc:creator>Jak Charlton</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/casey/rsscomments.aspx?PostID=42334</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/casey/commentapi.aspx?PostID=42334</wfw:comment><comments>http://devlicio.us/blogs/casey/archive/2008/09/17/asp-net-mvc-jquery-and-cross-view-javascript-events.aspx#comments</comments><description>&lt;p&gt;I wrote a nice little charting component for our site recently, and needed to call&amp;nbsp;a Javascript function in one View (the one that was the main page for charting), from another View (one that went off to the server using Ajax to load up a list of feeds that could be charted).&lt;/p&gt;
&lt;p&gt;This would have been traditionally done by putting a function on one View and calling it from another, but this is just a little bit &amp;quot;messy&amp;quot; and prone to breaking. Luckily I decided fairly early on to use &lt;a class="" href="http://jquery.com/"&gt;JQuery&lt;/a&gt; on this site (mostly as I hate writing Javascript and JQuery makes it a doddle). With JQuery I can define a Javascript event across the two views, thereby providing me with a loosely coupled way of achieving my objective.&lt;/p&gt;
&lt;p&gt;On my main index page I have:&lt;font size="4"&gt;&lt;/font&gt;&lt;font size="4"&gt; &lt;/font&gt;&lt;/p&gt;&lt;font size="4"&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Consolas;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-no-proof:yes;"&gt;$(&lt;span style="COLOR:#a31515;"&gt;&amp;#39;#graphFeeds&amp;#39;&lt;/span&gt;).bind(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;add&amp;quot;&lt;/span&gt;, &lt;span style="COLOR:blue;"&gt;function&lt;/span&gt;(e, feedId, description){&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;font size="4"&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Consolas;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;for&lt;/span&gt;(i=0;i&amp;lt;graphedFeeds.length;i++){&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Consolas;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;if&lt;/span&gt;(feedId==graphedFeeds[i].feedId) &lt;span style="COLOR:blue;"&gt;return&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;null&lt;/span&gt;;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Consolas;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt; &lt;/span&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Consolas;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;var&lt;/span&gt; theFeed = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; feed(feedId, description, &lt;span style="COLOR:#a31515;"&gt;&amp;quot;Green&amp;quot;&lt;/span&gt;, &lt;span style="COLOR:#a31515;"&gt;&amp;quot;Line&amp;quot;&lt;/span&gt;, 0, 1);&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Consolas;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;$(&lt;span style="COLOR:#a31515;"&gt;&amp;#39;#graphFeeds #table tbody&amp;#39;&lt;/span&gt;).append(createFeedTableRow(theFeed));&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Consolas;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;graphedFeeds.push(theFeed);&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;LINE-HEIGHT:115%;FONT-FAMILY:Consolas;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;});&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;LINE-HEIGHT:115%;"&gt;&lt;/span&gt; &lt;/font&gt;&lt;font size="4"&gt;
&lt;p&gt;&lt;/font&gt;And on the view that contains the list of feeds I have:&lt;/p&gt;&lt;span style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:Consolas;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-no-proof:yes;"&gt;function&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Consolas;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-no-proof:yes;"&gt; addFeed(feedId, description) {&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Consolas;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;$(&lt;span style="COLOR:#a31515;"&gt;&amp;#39;#graphFeeds&amp;#39;&lt;/span&gt;).trigger(&lt;span style="COLOR:#a31515;"&gt;&amp;#39;add&amp;#39;&lt;/span&gt;, [feedId, description]);}&lt;/span&gt; 
&lt;p&gt;Now by calling the addFeed() function on my list of feeds (I have a little &amp;quot;add to chart&amp;quot; link&amp;nbsp;to the right of each feed), the&amp;nbsp;Javascript event will be fired for the #graphFeeds div ... and the listening handler defined on the index view will go off on it&amp;#39;s merry way and add the selected feed into the chart.&lt;/p&gt;
&lt;p&gt;Much as I hate Javascript, I love &lt;a class="" href="http://jquery.com/"&gt;JQuery&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=42334" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/casey/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://devlicio.us/blogs/casey/archive/tags/Javascript/default.aspx">Javascript</category><category domain="http://devlicio.us/blogs/casey/archive/tags/JQuery/default.aspx">JQuery</category></item></channel></rss>