<?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>Position Absolute, resources for the web developer &#187; Javascript / jQuery</title>
	<atom:link href="http://www.position-absolute.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.position-absolute.com</link>
	<description>Get your web worker news fix</description>
	<lastBuildDate>Mon, 06 Feb 2012 15:17:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Launching my first product</title>
		<link>http://www.position-absolute.com/articles/launching-my-first-product/</link>
		<comments>http://www.position-absolute.com/articles/launching-my-first-product/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 05:20:55 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[featured]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3932</guid>
		<description><![CDATA[<p>Some of you guys probably know that I have been working on a project for some time. I finally got around of fixings the last couple of bugs and so today I am launching <a href="http://www.weddingdeck.com">weddingdeck.com, whitelabel wedding planner</a>. </p>
<h2>The Pitch</h2>
<p>When&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Some of you guys probably know that I have been working on a project for some time. I finally got around of fixings the last couple of bugs and so today I am launching <a href="http://www.weddingdeck.com">weddingdeck.com, whitelabel wedding planner</a>. </p>
<h2>The Pitch</h2>
<p>When I look at people getting married it always seems like a lot of stress is involved in the process. This tool is suppose to relieve that stress for a very small fee. It&#8217;s also whitelabel, that means that professional wedding planners can add their logo and sell it at their own tool to their clients for a monthly fee.</p>
<p>Like I said it&#8217;s a MVP, don&#8217;t expect a onslaught of features, I&#8217;m trying to focus on a small set of features and build them to be useful in the long term. I also have a lot of ideas to complement or pivot a bit the project. I think the wedding niche can be disrupted and there is a lot of space to do it. I have been developing this project for 4-6 months and I think it was time to do a small breakdown of how this experience has been for me.</p>
<p><img src="http://weddingdeck.com/_include/images/img_imac.png"></p>
<h2>My stack</h2>
<p>My app is primary a front-end saas. I use jQuery + Backbone.js as a front-end MVC. This allows me to reuse much of my code on the mobile web app because it uses jQuery Mobile + Backbone.js. In the future I will also release a native app on Android &#038; IPhone using Phonegap. It will be my mobile web app + taking photos functionality. I&#8217;m really happy of that stack, it makes moving fast really easy on mobile from my desktop app (at the cost of not having a native look). Without that stack there is no way I could release an Android &#038; iPhone app alone.</p>
<h3>Frameworks! Out of my way!!</h3>
<p>If you know PHP, don&#8217;t start something with Ruby or a big enterprise framework (unless it&#8217;s educational first). You move faster with tools you know, I&#8217;m a front-end developer, my app is front-end heavy. For the API use Codeigniter because it&#8217;s easy, swift, small, and is used by a lot of people. I did the error to start with Symfonybefore and lost countless hours learning intricacies of the magic behind Symfony.</p>
<h2>It&#8217;s cheaper than ever to create web products</h2>
<p>Something I really leveraged with this product is the cheap price of online services. If you are bad at design, html, video it does not really matter, at least not for the first couple of months of your company.</p>
<p>Introducing <a target="_blank" href="http://themeforest.net">themeforest.net</a> and the <a target="_blank" href="http://envato.com/">Envato network</a>. On the Envato network you can find pretty much anything you need for your startup, and it&#8217;s all superior quality and cheap price. Personally, I&#8217;m not really good at design, so ThemeForest really helped me find saas templates and saas marketing designs that look professional, I also bough a really nice template card and email template. </p>
<p>That way I really concentrated my efforts on building the saas user experience and moving forward faster with a project that looks nice.</p>
<h3>You don&#8217;t need big hosting</h3>
<p>If you are bootstrapping you don&#8217;t need big server, in fact a cheap 10 bucks hosting from <a target="_blank" href="http://webfaction.com">Webfaction </a> would do. They even have a SMTP server with good rating for sending your transactional emails. Their servers are fast and not overcrowded, of course if you build up a big enough clients base you will have to switch. But think about this : this blog is on Webfaction getting more than 100 000 views a month and its running as fast as Wordpress allows it. </p>
<p>You don&#8217;t need to scale now, at least I&#8217;m not.</p>
<h2>Finding time is hard</h2>
<p>I think that one is obvious but bootstrapping products is time consuming and you can get quite obsessed with it. I guess being obsessed is good for the product but definitely bad for you. Obviously I got other ideas for weddingdeck, bigger ideas, but for now here you go, even if your not getting married have a try at the product and hit the suggestion box!</p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/launching-my-first-product/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using the jQuery Validation Engine with modal &amp; dialog plugins</title>
		<link>http://www.position-absolute.com/articles/using-the-jquery-validation-engine-with-modal-plugins/</link>
		<comments>http://www.position-absolute.com/articles/using-the-jquery-validation-engine-with-modal-plugins/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 20:49:27 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[featured]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3936</guid>
		<description><![CDATA[<p>This is a question I often get asked by email, and I think there is enough requests to warrant a small blog post.</p>
<h2>All about the DOM </h2>
<p>The validationEngine expect your form to be present on the page when you initialize&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>This is a question I often get asked by email, and I think there is enough requests to warrant a small blog post.</p>
<h2>All about the DOM </h2>
<p>The validationEngine expect your form to be present on the page when you initialize the plugin, and this is where modal plugins fall short. If your using those plugins you generally want to load a new piece of html into your document using AJAX.</p>
<p>In that case you need to initialize the validationEngine <strong>after</strong> you loaded your modal content. Generally modal plugins have an api that let you do this. Let&#8217;s take 2 example, Colorbox and jQuey ui.</p>
<p><strong>Colorbox :</strong></p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1">$<span class="br0">&#40;</span>document<span class="br0">&#41;</span>.<span class="me1">bind</span><span class="br0">&#40;</span><span class="st0">&#39;cbox_complete&#39;</span>, <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&quot;#formID&quot;</span><span class="br0">&#41;</span>.<span class="me1">validationEngine</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p><strong>jQuery UI :</strong></p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1">$<span class="br0">&#40;</span> <span class="st0">&quot;.selector&quot;</span> <span class="br0">&#41;</span>.<span class="me1">bind</span><span class="br0">&#40;</span> <span class="st0">&quot;dialogopen&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span>event, ui<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;$<span class="br0">&#40;</span><span class="st0">&quot;#formID&quot;</span><span class="br0">&#41;</span>.<span class="me1">validationEngine</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>That should give you a pretty good idea of what you need to do whatever the plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/using-the-jquery-validation-engine-with-modal-plugins/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Working with jQuery load() function on images in Internet Explorer 8 and below</title>
		<link>http://www.position-absolute.com/articles/working-with-jquery-load-function-in-internet-explorer-8-and-below/</link>
		<comments>http://www.position-absolute.com/articles/working-with-jquery-load-function-in-internet-explorer-8-and-below/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 20:11:39 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Article small archives]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3819</guid>
		<description><![CDATA[<p>One big problem with using load() on images is that it just does not work at all on ie. Now there is a lot of solutions proposed to counter this problem, however most of them are irritating.</p>
<h2>Why IE handle load()&#8230;</h2>]]></description>
			<content:encoded><![CDATA[<p>One big problem with using load() on images is that it just does not work at all on ie. Now there is a lot of solutions proposed to counter this problem, however most of them are irritating.</p>
<h2>Why IE handle load() this way</h2>
<p>Simple, IE already cached your image, so it does not need to load it back The 2 most know solution to this are one, adding a random string at the end of the image url, like this:</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1">myImge = $<span class="br0">&#40;</span><span class="st0">&quot;&lt;img /&gt;&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;.<span class="me1">attr</span><span class="br0">&#40;</span><span class="st0">&quot;src&quot;</span>,anyDynamicSource+ <span class="st0">&quot;?&quot;</span> + <span class="kw2">new</span> Date<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">getTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>The other solution is to check the height property since if it&#8217;s not zero, the image is already loaded:</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1">$<span class="br0">&#40;</span><span class="st0">&#39;img&#39;</span><span class="br0">&#41;</span>.<span class="me1">each</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>$<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">height</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&gt;</span> <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;our callback</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;$<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">load</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;our callback</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>Well these 2 solutions work, but they are not really nice. In fact this problem can be solved a lot easier.</p>
<h2>Use load() first</h2>
<p>Yup. That&#8217;s it, when you create your image in javascript, before doing anything else use your load function and IE will behave like all the other browsers.</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1">$<span class="br0">&#40;</span><span class="st0">&quot;&lt;img&gt;&quot;</span><span class="br0">&#41;</span>.<span class="me1">load</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;<span class="co1">// do stuff</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>.<span class="me1">attr</span><span class="br0">&#40;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="st0">&quot;id&quot;</span>:<span class="st0">&quot;imgInsert&quot;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="st0">&quot;src&quot;</span>:response.<span class="me1">url</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="st0">&quot;alt&quot;</span>:response.<span class="me1">alt</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/working-with-jquery-load-function-in-internet-explorer-8-and-below/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Update on mobile web frameworks</title>
		<link>http://www.position-absolute.com/news/update-on-mobile-web-frameworks/</link>
		<comments>http://www.position-absolute.com/news/update-on-mobile-web-frameworks/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 11:28:33 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[News small archive]]></category>
		<category><![CDATA[Random news]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3807</guid>
		<description><![CDATA[<p>Recently saw 2 developments on web mobile frameworks that really got my attention. </p>
<h2>jQuery Mobile</h2>
<p>First, jQuery mobile just entered Beta3. Lots of bugfixes but also one cool thing that has been baking for a while, real fixed footers and headers&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Recently saw 2 developments on web mobile frameworks that really got my attention. </p>
<h2>jQuery Mobile</h2>
<p>First, jQuery mobile just entered Beta3. Lots of bugfixes but also one cool thing that has been baking for a while, real fixed footers and headers are available in the framework. Before that, jQuery fixed stuff was just a gimmick with the fixed bars disappearing when scrolling, now you got the real deal, <em>well sort of</em>. It&#8217;s unfortunately only available for ios5, meaning not a big lot of people will see it. </p>
<p>Android does not really support fixed positioning yet, it however supports overflow:scrolltouch. But it seems the jQ teams decided to only implement  position:fixed for everybody. There is a nice video of the feature <a href="http://jquerymobile.com/blog/">here</a>.</p>
<h2>Sencha Touch</h2>
<p>Sencha kind of went off the radar for sometimes now, but they just announced something really hot. Sencha Touch version 2 will include a native packaging that will automatically transform your web apps into native apps on android and ios, on osx and windows.</p>
<p>Now I don&#8217;t know if they really went there and added ios app native packaging on Windows, but that would be legend&#8230; wait for it&#8230; wait for it&#8230; legendary! <a href="http://www.sencha.com/blog/sencha-touch-2-what-to-expect/">More information here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/news/update-on-mobile-web-frameworks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Organizing events with jQuery</title>
		<link>http://www.position-absolute.com/articles/organizing-events-with-jquery/</link>
		<comments>http://www.position-absolute.com/articles/organizing-events-with-jquery/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 12:07:47 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3773</guid>
		<description><![CDATA[<p><br />
Following the launch of <a href="http://www.backbonefu.com">BackboneFU</a> I wanted to take the time to talk about my current setup when I am not using an MVC framework on the front-end. This will be also part of my presentation at Confoo 2011 (if I&#8217;m&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><!-- {EAV_BLOG_VER:d174f150c64c385e} --><br />
Following the launch of <a href="http://www.backbonefu.com">BackboneFU</a> I wanted to take the time to talk about my current setup when I am not using an MVC framework on the front-end. This will be also part of my presentation at Confoo 2011 (if I&#8217;m chosen).</p>
<p>The problem with handling events with jQuery is probably that jQuery itself makes it really easy to make spaghetti code, so only reading the jQuery documentation you are bound to hit a wall at some point. I&#8217;m always amazed at junior javascript developers&#8217; code and how they always mess things up if they use jQuery.</p>
<h2>Prob #1 Anonymous functions</h2>
<p>When you look at the jQuery documentation for events, you would see something like this explaining bind:</p>
<div class="geshi no javascript">
<div class="head">$(&#8220;#myButton&#8221;).bind(&#8220;click&#8221;, function(){</div>
<ol>
<li class="li1">
<div class="de1">&nbsp;$<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">&quot;selected&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>It&#8217;s not because you can use anonymous function to do everything that you should, use simple objects for that.</p>
<div class="geshi no javascript">
<div class="head">var myapp.dashboard = {</div>
<ol>
<li class="li1">
<div class="de1">&nbsp;loadEvents: <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">var</span> _this = <span class="kw1">this</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span><span class="st0">&quot;#myButton&quot;</span><span class="br0">&#41;</span>.<span class="me1">bind</span><span class="br0">&#40;</span><span class="st0">&quot;click&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> &nbsp;_this.<span class="me1">selectedOption</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span><span class="st0">&quot;#myButton2&quot;</span><span class="br0">&#41;</span>.<span class="me1">bind</span><span class="br0">&#40;</span><span class="st0">&quot;click&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> _this.<span class="me1">doSomething</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp;selectedOption : <span class="kw2">function</span><span class="br0">&#40;</span>el<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span>el<span class="br0">&#41;</span>.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">&quot;selected&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp;doSomething : <span class="kw2">function</span><span class="br0">&#40;</span>el<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<h3>What is the deal with &#8220;this&#8221;</h3>
<p>jQuery always assigns the <em>this</em> value on the DOM element when you bind events, pretty useful, but not really good if we use objects and want to call other methods, that is why I pass the <em>this</em> value as a parameter in loadEvents().</p>
<p>Also since the anonymous function changes our scope we need to save the <em>this</em> value doing var _this = this; at the beginning of the method to use it later.</p>
<p>Using an object you will give you a much better code organization, as a bonus you see every events binded in the js file easily.</p>
<h2>Give a context</h2>
<p>If you are the kind that dump every js files at the beginning of each page, giving a context to your events can be a very good idea.</p>
<p>Personally I really like to use a parent element for that, for example, I know that everything that happens on the dashboard has a parent with the css class <em>dashboard</em>. So I would do something like this:</p>
<div class="geshi no javascript">
<div class="head">var myapp.dashboard = {</div>
<ol>
<li class="li1">
<div class="de1">&nbsp;loadEvents: <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">//Check if we are in the right section</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">var</span> $dashboard = $<span class="br0">&#40;</span><span class="st0">&quot;.dashboard&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span>$dashboard<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="kw1">return</span> <span class="kw2">false</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// Save the this value for later</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">var</span> _this = <span class="kw1">this</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// Delegate give a context to our events</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $dashboard.<span class="me1">delegate</span><span class="br0">&#40;</span><span class="st0">&quot;#myButton&quot;</span>,<span class="st0">&quot;click&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> &nbsp;_this.<span class="me1">selectedOption</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; $dashboard.<span class="me1">delegate</span><span class="br0">&#40;</span><span class="st0">&quot;#myButton2&quot;</span>,<span class="st0">&quot;click&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> _this.<span class="me1">doSomething</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp;selectedOption : <span class="kw2">function</span><span class="br0">&#40;</span>el<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span>el<span class="br0">&#41;</span>.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">&quot;selected&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp;doSomething : <span class="kw2">function</span><span class="br0">&#40;</span>el<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">$<span class="br0">&#40;</span>document<span class="br0">&#41;</span>.<span class="me1">ready</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span> myapp.<span class="me1">dashboard</span>.<span class="me1">loadEvents</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>On this line: <em>if(!$(&#8220;.dashboard&#8221;)[0]) return false;</em> we check if the dashboard element exist, and if it does not, we do not load the events, It can save you a lot of overhead at practically no cost. Then we use delegate instead of bind, so if we want to convert this app to an ajaxy app, events would be automatically destroyed if we removed the dashboard element.</p>
<h2>That&#8217;s it!</h2>
<p>I just wanted to share my current code organization, hope it can give you ideas for your organization too!</p>
<h2>Update</h2>
<p>Following some commenters ideas, there is a couple of things we could do to improve this.</p>
<p>First, we can use <em>!$dashboard.length </em>instead of <em>!$dashboard[0],</em> little bit clearer.</p>
<p>Lets chain the delegate! Since we always use the same parent this is something we can do. Also, wrapping into an anonymous function is not the best idea in the world, 2 things have been proposed here.</p>
<p>We could use jQuery proxy like this <em>$.proxy(this.selectedOption, this),</em> or we could do something like <em>$dashboard.delegate(“#myButton”,”click”, { dashboard: this }, this.selectedOption);</em>.</p>
<p>So lets check our new formula:</p>
<div class="geshi no javascript">
<div class="head">var myapp.dashboard = {</div>
<ol>
<li class="li1">
<div class="de1">&nbsp;loadEvents: <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">//Check if we are in the right section</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">var</span> $dashboard = $<span class="br0">&#40;</span><span class="st0">&quot;.dashboard&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span>$dashboard.<span class="me1">length</span><span class="br0">&#41;</span> <span class="kw1">return</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// Save the this value for later</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">var</span> _this = <span class="kw1">this</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// Delegate give a context to our events</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $dashboard</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;.<span class="me1">delegate</span><span class="br0">&#40;</span><span class="st0">&quot;#myButton&quot;</span>,<span class="st0">&quot;click&quot;</span>, &nbsp;$.<span class="me1">proxy</span><span class="br0">&#40;</span><span class="kw1">this</span>.<span class="me1">selectedOption</span>, <span class="kw1">this</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;.<span class="me1">delegate</span><span class="br0">&#40;</span><span class="st0">&quot;#myButton2&quot;</span>,<span class="st0">&quot;click&quot;</span>, &nbsp;$.<span class="me1">proxy</span><span class="br0">&#40;</span><span class="kw1">this</span>.<span class="me1">doSomething</span>, <span class="kw1">this</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp;selectedOption : <span class="kw2">function</span><span class="br0">&#40;</span>el<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span>el<span class="br0">&#41;</span>.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">&quot;selected&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp;doSomething : <span class="kw2">function</span><span class="br0">&#40;</span>el<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">$<span class="br0">&#40;</span>document<span class="br0">&#41;</span>.<span class="me1">ready</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span> myapp.<span class="me1">dashboard</span>.<span class="me1">loadEvents</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/organizing-events-with-jquery/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Introducing BackboneFU.com, the resources for Backbone.js.. maybe</title>
		<link>http://www.position-absolute.com/news/backbonefu-com-the-ressources-for-backbone-maybe/</link>
		<comments>http://www.position-absolute.com/news/backbonefu-com-the-ressources-for-backbone-maybe/#comments</comments>
		<pubDate>Sun, 28 Aug 2011 18:52:10 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[News small archive]]></category>
		<category><![CDATA[Random news]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3761</guid>
		<description><![CDATA[<p>Well, well, sometimes I feel that I need to start a small project just for the fun of it, this time I created <a href="http://www.backbonefu.com">backboneFU</a>. I recently started playing with this framework and while there is a lot of resources about&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Well, well, sometimes I feel that I need to start a small project just for the fun of it, this time I created <a href="http://www.backbonefu.com">backboneFU</a>. I recently started playing with this framework and while there is a lot of resources about backbone, I feel that it&#8217;s missing a community website like railcasts for Rails.</p>
<p>This is why I started BackboneFU, in my wildest dreams it would become the resource for Backbone. Anyone who wants to write about backbone will be accepted on the website, so if you want to write something, or already wrote something on your blog and donate the article also on BakcbonFU, you are welcome to do so. There is a nice bio for authors on each articles.</p>
<p>I also added one article recently, <a href="http://backbonefu.com/2011/08/front-end-developer-to-backbone-js-what-you-need-to-know/">Front-end developers to backbone.js</a>.</p>
<p>So there you have it, BackboneFU lives <img src='http://www.position-absolute.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/news/backbonefu-com-the-ressources-for-backbone-maybe/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Two headaches explained when you&#8217;re getting started with backbone.js</title>
		<link>http://www.position-absolute.com/articles/two-headaches-explained-when-youre-getting-started-with-backbone-js/</link>
		<comments>http://www.position-absolute.com/articles/two-headaches-explained-when-youre-getting-started-with-backbone-js/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 02:26:10 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3739</guid>
		<description><![CDATA[<p>Recently I decided to dive into backbone.js. I tried to write a small project with it but I found it was hard to get into and abandoned. After seeing a presentation of it at<a href="http://www.js-montreal.org"> JS-Montreal</a>, I finally decided to give it&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Recently I decided to dive into backbone.js. I tried to write a small project with it but I found it was hard to get into and abandoned. After seeing a presentation of it at<a href="http://www.js-montreal.org"> JS-Montreal</a>, I finally decided to give it another try and started porting a project I was working on to it.</p>
<p>Personally I find that <a href="http://documentcloud.github.com/backbone/">backbone.js</a> is a weird beast. It&#8217;s called an MVC framework, but there is no controller, the events system is completely different from your default PHP/Ruby MVC style and there is a notion of collections. Basically Backbone is a MRVT(Model Route Views Template), scratch that, it&#8217;s in fact a MCRVT(Model Collection Route View Template)</p>
<p>So if you are a front-end developer with some MVC knowledge because you are sometimes dealing with a back-end framework you will probably be completely lost. Then you start reading the doc, it seems good and gets you 80% there, but trying to start only with the doc will probably end in pain. Then you go to the todo app example, you understand a little bit more the concepts but there is still lot of WTF.</p>
<p>Then, you <a href="http://backbonetutorials.com/">search</a> for <a href="http://thomasdavis.github.com/tutorial/backbone-introduction.html">tutorials</a>, the <a href="http://net.tutsplus.com/tutorials/javascript-ajax/getting-started-with-backbone-js/">nettuts</a> tutorial is particularly good. But personally I had problems with what is not really explained in those tutorials, I guess you could call that &#8220;edges cases&#8221;. Only the videos at <a href="http://peepcode.com/products/backbone-js">peepscode</a> (Did not want to do promotion, but credits where it is due) where successful at really showing me all the power of backbone and really helped me understand all the underlying concepts that come with that.</p>
<p>So anyway, what was the 2 problems I have been struggling with? Well for one when I was binding a collection to a method within my view, I would lose the <strong>this</strong> reference to my view in that method, and also, my events would not bind to my views and would just never fire.</p>
<h2>Events Binding In The Views</h2>
<p>In backbone, the views control all the events that are happening &#8220;in this part of html code&#8221; (in other words, your associated template). Which is really good for decoupling your code, and makes for a very good code structure. Events are handled automatically with jQuery delegates, thing is, the dom element that delegates all the events need to be outside the view, something I did not understand at first. It makes also no sense to me that I can&#8217;t delegate my events from within my view, what happen if the view is a popup? I don&#8217;t want to delegate to the document.</p>
<p>Fortunately something  you can do after your view content is rendered is changing the <em>this.el</em> element to the view container and call <em>this.delegateEvents(this.events)</em> . That took care of the event binding problem.</p>
<p><strong>Update from Josh comment:</strong><br />
If you assign ‘el’ directly to the view and remove it from render, the dom element that delegates all the events will be part of your view. Based on your example, do:</p>
<p>wedapp.view.TasksForm = Backbone.View.extend({<br />
el: $(“.dialogForm”),<br />
…You can then remove this.delegateEvents from render as well.</p>
<p>Example:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">wedapp.view.TasksForm = Backbone.View.extend({
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;events: {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;click #completedbtn&quot; : &nbsp;&quot;complete&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;click #updatebtn&quot; : &nbsp; &quot;update&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;click #savebtn&quot; : &nbsp; &nbsp;&quot;save&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;click #closebtn&quot; : &nbsp; &quot;close&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;},
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;render: function() {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; var data = (this.model.has(&quot;name&quot;) ) ? this.model.toJSON() : this.model.default;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; var formString = this.template(data);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; $(formString).dialog({
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;autoOpen: true,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;height: 460,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;width: 350,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;title:&quot;Tasks&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;modal: true
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; })
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; this.el = $(&quot;.dialogForm&quot;);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; this.delegateEvents(this.events)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; return this;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;},
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;initialize : function(){
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; _.bindAll(this,&quot;render&quot;)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; this.template = _.template($(&quot;#task_form_tpl&quot;).html());
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; this.render().el;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;},
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;complete: function(){
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; console.log(&quot;crap&quot;)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;},
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;update: function(){
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;},
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;save: function(){
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;},
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;close: function(){
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;},
</div>
</li>
<li class="li1">
<div class="de1">});</div>
</li>
</ol>
</div>
<h2>Weird Custom Events Behaviors</h2>
<p>Backbone has a custom events system baked-in which makes it really simple to handle model states. This is really powerful since when you update a row in your database, for example, the html for that row would be automatically rendered back when you change the data. No DOM data tags non-sense.</p>
<p>Problems is, doing <em>this.collection(&#8216;reset&#8217;, handleCollection)</em> changes the <strong>this</strong> handle to the collection! I was wondering why in <em>handleCollection()</em> I could not call any other method from my current view. Of course I logged <strong>this</strong> to see what was happening, but since backbone is very particular of what it returns I did not see that handleCollection was returning the collection instead of the view object.</p>
<p>What you need to do for retaking control of <strong>this</strong>, is to bind it to the view in the initialize method like this: <em>_.bindAll(this,&#8221;handleCollection&#8221;)</em> . Personally I don&#8217;t think it makes sense to handle it that way and it pains me to add this code, but here is no other way that I know of.</p>
<p><strong>Update from Josh comment:</strong><br />
If you want to bind your collection to a callback event, do: this.collection.bind(‘reset’, this.handleCollection, this)</p>
<p>If you pass “this” as the third parameter, you won’t need to do your _.bindAll() in initialize for that method. I’m assuming here that handleCollection is a method in the view.</p>
<h2>Hope it helps!</h2>
<p>I am a bit disappointed that backbone.js is so hard to get started with. It introduces a lot of concept to front-end developers and do not have enough tools to guide you around. </p>
<p>I think tutorial videos through each sections would really help a lot the beginners understanding all the underlying concepts of backbone, I even thought about doing some myself but I&#8217;m too much inexperience with it to do that. In fact I think that a getting started guide like rails for zombies would be perfect, but hey, I know it is a lot of work <img src='http://www.position-absolute.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/two-headaches-explained-when-youre-getting-started-with-backbone-js/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Do you use script loaders?</title>
		<link>http://www.position-absolute.com/articles/do-you-use-script-loaders/</link>
		<comments>http://www.position-absolute.com/articles/do-you-use-script-loaders/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 16:21:05 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Article small archives]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3711</guid>
		<description><![CDATA[<p>It&#8217;s funny I have the impression that script loaders keep coming back in the news, if we go back one year and a half ago  we mostly only had <a href="http://labjs.com">labJS</a> and <a href="http://requirejs.com">requireJS</a>, these guys want to load all your scripts asynch,&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s funny I have the impression that script loaders keep coming back in the news, if we go back one year and a half ago  we mostly only had <a href="http://labjs.com">labJS</a> and <a href="http://requirejs.com">requireJS</a>, these guys want to load all your scripts asynch, but now we got new kids, notably <a href="http://yepnopejs.com/">yepnope</a>, that allows you to load scripts based on feature detection and others.. <a href="http://headjs.com/">headJS</a>, <a href="http://stevesouders.com/controljs/">controlJS</a>, <a href="http://filamentgroup.com/lab/introducing_enhancejs_smarter_safer_apply_progressive_enhancement/">enhanceJS</a>, <a href="https://github.com/BorisMoore/jsdefer">jsDefer</a> ouch&#8230; </p>
<p>Script loaders are responding to a weird problem, you would think that browsers do a good job at loading script since its been doing just that for more than 10 years, but in fact not really, it could be a lot better and this is where those technologies come in.</p>
<p>What they do is super charge the loading speed of your scripts by using various tricks, and when I say tricks, sometimes it really means hacks, specially in older browsers like ie6. In my <a href="http://www.position-absolute.com/articles/optimizing-javascriptjquery-loading-time-a-beginners-guide/">article about script loaders 1 year ago</a> I gave them praised, and I definitely meant it, but currently I unfortunately just stopped using loaders.</p>
<h2>What went wrong?</h2>
<p>When I first tested labJS I was flabbergasted, it was loading my scripts 3 times faster on a average website. I was looking at optimizing the front-end speed of our framework at my last job (w.illi.am/ a web consulting/agency), and this was a strong contender at being implemented. And we did just that, we implemented labJS at the core of our CMS. It definitely took some fine tuning and we had some weird bugs at first with execution order and dom ready statements, but within a week or 2 everything was back to normal.</p>
<p>Then a new project came with an IE phase testing, to our horror IE8 was giving us wrong error lines, it did not understand what labJS was doing and could not find any script file loaded by labjs. Still we continued to use it. Then Firefox4 came along, our older labjs version was not compatible with it, this was a big problem for us, since w.illi.am/ does something like 50 websites a year, not centralized. We just could not afford to update labJS for each project. This was the end of script loading for us, we had to revert back to our old way, we could not take the chance that older version would not be compatible with future browsers.<br />
<em><br />
** I also heard that some of them had problems with newer webkit releases, prompting another library update.</em></p>
<h2>Is it really worth it to use a script loader?</h2>
<p>Personally my response would be no, you introduce in your stack a <strong>very big point of failure</strong>, if this script fails, your entire app fails, furthermore you *generally* need to follow convention dictated by the library. RequireJS works best if you follow their module convention, and labJS has an api to make it easier to keep the execution order, but it really changes the way you would normally work. </p>
<p>I&#8217;m no more at w.illi.am/, but at Cakemail we are currently minifying everything we can into one big js file, like what javascriptMVC does, and loading it normally. It seems to me as the best approach, *some* scripts minifier have been stable for ages, so I know that my production application will not break because of it (it can happen of course, but it is really rare), and in development we just keep the gazillions of script tags for debugging. </p>
<p>That being said, I still think script loaders are a brilliant technology, and I have a lot of respect for their authors. I mean, if your looking for optimizing your page loading time to the maximum, script loaders are a no brainer, its probably your single best optimization beside doing the <a href="http://developer.yahoo.com/performance/rules.html">normal stuff</a>, but it&#8217;s not a task to be taken lightly and you must be aware that there will be maintenance and setup cost.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/do-you-use-script-loaders/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Authoring a css book and what is next</title>
		<link>http://www.position-absolute.com/news/authoring-a-css-book-and-what-is-next/</link>
		<comments>http://www.position-absolute.com/news/authoring-a-css-book-and-what-is-next/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 17:03:06 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[CSS / HTML]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[Random news]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3704</guid>
		<description><![CDATA[<p>I neglected quite a bit my blog for some times now .. After 3 years of doing this I  feel like I have less and less to say about web development. Well not that it happens to every blogs of&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>I neglected quite a bit my blog for some times now .. After 3 years of doing this I  feel like I have less and less to say about web development. Well not that it happens to every blogs of course <img src='http://www.position-absolute.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> . I still have some stuff for you guys, but I feel my time doing one article a week is gone.</p>
<h2>Confoo conference</h2>
<p>This year I am trying to do a talk at the <a href="http://confoo.ca/en/call-for-papers/1028">Confoo conference</a>, basically it&#8217;s an introduction course at code organization with jQuery, called jQuery Spaghetti. It&#8217;s probably not for most of you guys and I know it has been done in other js conferences, but I feel like Confoo will have quite a bit of &#8216;hobby&#8217; jQuery devs since it&#8217;s really a diverse conference about all web technologies (hoo and it is also in french). Still, if you like the idea and you&#8217;re in Montreal, I could use a vote or 2 for <a href="http://confoo.ca/en/call-for-papers/1028">my talk</a>. (You can downvote too, any feedback is appreciate!)</p>
<h2>Self-publishing a book</h2>
<p>Did you know that anyone can wrote a book and self-publish it these days? and I am not talking about  doing a pdf, I&#8217;m talking about a paperback book available from amazon. This is what <a href="http://lulu.com">lulu.com</a> and <a href="http://createspace.com">createspace.com</a> are offering. It does all the hard work for you (well beside writing the book of course).</p>
<p>It&#8217;s quite impressive to upload a pdf and have a paperback available from online stores, and even physical book stores with lulu.</p>
<h2>A book on css, really?</h2>
<p>Yup, I am writing a book about html and css templating, this has been done 30 times you might say, but I really think the approach I am taking has not been that used. In this book I am not talking about HTML5, CSS3, grids, etc. I am talking about doing templating efficiently on deadlines with a cross-browsers angle. </p>
<p>The book will walk you through 2 examples (a website homepage and an email), and explain you the problems you will encounter along the way. I&#8217;m already 80% done with the writing, but doing image assets takes quite a bit of times.</p>
<h2>A book looking professional</h2>
<p>Obviously if you are authoring a book, you want it to look professional. Unfortunatly most of us are not designers. Fortunately there is a couple of inDesign book template available, I even found one free, and its a really nice <a href="http://www.stockindesign.com/inicio/item/book-template-aristo">book template</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/news/authoring-a-css-book-and-what-is-next/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Handling javascript errors on production websites</title>
		<link>http://www.position-absolute.com/articles/handling-javascript-errors-on-production-websites/</link>
		<comments>http://www.position-absolute.com/articles/handling-javascript-errors-on-production-websites/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 21:41:51 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[Small Projects & plugins]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3636</guid>
		<description><![CDATA[<p>Handling javascript errors as always been sort of a problem for me. Testing every combination possible in a big application is hard, and there is always a chance you will miss something.</p>
<p>Of course, we should always strive to make an&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Handling javascript errors as always been sort of a problem for me. Testing every combination possible in a big application is hard, and there is always a chance you will miss something.</p>
<p>Of course, we should always strive to make an application as bug free as possible, but users seems to always find a way to break it. You can always expect them to do something you never have think of, and this is one of the reason I created this plugin.</p>
<p>When a javascript error is detected, this plugin will do an ajax request to your server and then sends an email, of course you could also log it in a database. It&#8217;s certainly not a revolutionary idea, but still, I was finding the idea cool enough to add it to my list of online plugin.</p>
<p>It&#8217;s also very useful for debugging big live applications that you have not written. In which case you want to know if some users hit javascript errors already.</p>
<p class="clearfix"><a class="download" href="https://github.com/posabsolute/jQuery-Error-Handler-Plugin">Download the source code</a></p>
<h2>Integration</h2>
<p>Load the plugin just after the jQuery library</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; $(document).jsErrorHandler();</div>
</li>
</ol>
</div>
<p>Your done.</p>
<h2>Options</h2>
<p>By default the plugin automatically fetch the domain and add it to the email subject, but you can overwrite it.<br />
You can also define a from attribute, I would highly recommend that you change the from setting in the plugin file (jquery.onerror.js)  if your going to use this plugin on multiple websites.</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;$(document).jsErrorHandler({
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; from: &quot;support@youremail.com&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; website: document.domain
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;});</div>
</li>
</ol>
</div>
<h2>The Email</h2>
<p>The email received will look like this:</p>
<p>A javascript error has been detected on www.position-absolute.com</p>
<p>Error: variable is not defined<br />
Url: http://www.position-absolute.com/creation/onerror/<br />
Line: 21<br />
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0</p>
<h2>Limitation</h2>
<p>The plugin works on:<br />
Firefox 3.6+<br />
Chrome Latest<br />
IE 7+</p>
<p>It does not work on Safari (but it will not break your application)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/handling-javascript-errors-on-production-websites/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

