<?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&#039;s Drivelings &#187; jQuery</title>
	<atom:link href="http://www.tntechnohermit.com/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tntechnohermit.com</link>
	<description>Random Thoughts of a Techno-Hermit</description>
	<lastBuildDate>Thu, 01 Sep 2011 16:37:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Returning ColdFusion 9 ORM objects with JSON</title>
		<link>http://www.tntechnohermit.com/2010/07/19/returning-coldfusion-9-orm-objects-with-json/</link>
		<comments>http://www.tntechnohermit.com/2010/07/19/returning-coldfusion-9-orm-objects-with-json/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 16:26:26 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=413</guid>
		<description><![CDATA[Last week I was working on a client&#8217;s project that makes heavy use of ColdFusion 9&#8242;s ORM features. Everything we&#8217;d done with ORM up to that point had been going really well and I continue to be impressed by the amount of time ORM saves me in development. I had gotten to a point in [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I was working on a client&#8217;s project that makes heavy use of ColdFusion 9&#8242;s ORM features. Everything we&#8217;d done with ORM up to that point had been going really well and I continue to be impressed by the amount of time ORM saves me in development. I had gotten to a point in the project where I needed to be able to use AJAX calls from jQuery to manage some of the data in the database. Based on my experiences using a RemoteFacade.cfc to feed data to a Flex app, I thought it should be pretty easy. Several hours later, I realized that my particular use case for this was anything but easy.<br />
<span id="more-413"></span></p>
<p>What I eventually found was, when trying to load an object using an AJAX call to RemoteFacade.cfc, any object that had a property that was an array of other objects was not returned to Javascript. It wasn&#8217;t even that it was sent across as an empty property. The property absolutely didn&#8217;t exist in the JSON returned by the CFC. I used the ColdFusion debugger to verify that the array existing in the object immediately prior to the &lt;cfreturn&gt; statement and then examined the JSON return using Charles Proxy only to find out that those properties weren&#8217;t in the JSON.  All the normal string, numeric, date, etc type properties were returned just fine, but any properties composed of other objects were missing.</p>
<p>As near as I can tell, the culprit is the serializeJSON() method that ColdFusion uses to convert complex objects into JSON notation. It doesn&#8217;t seem to work correctly on ORM objects. To test my theory, I manually built a structure and inserted each simple property from the ORM object. I then created a key in the structure that was an array and manually populated several items in the array each with a structure of data. When I returned that from the CFC as JSON, the array and all the structures it contained came across the wire just fine.</p>
<p>I&#8217;m not sure if this is a bug in the serializeJSON() method or if serializeJSON() wasn&#8217;t meant to handle objects. Whatever the case, this issue leads to quite a bit of extra work if you need to return an object via JSON and include its properties that are composed of other objects. I&#8217;d definitely be interested in hearing from anyone who has successfully done this with ORM and AJAX to see if I&#8217;ve done something incorrectly in my code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tntechnohermit.com/2010/07/19/returning-coldfusion-9-orm-objects-with-json/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>jQuery head-scratcher and lesson learned</title>
		<link>http://www.tntechnohermit.com/2010/02/01/jquery-head-scratcher/</link>
		<comments>http://www.tntechnohermit.com/2010/02/01/jquery-head-scratcher/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 15:42:02 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[ModelGlue]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=343</guid>
		<description><![CDATA[As I mentioned in my last post, I&#8217;m working on a pet project in my spare time. It uses jQuery in various places including in the site design template that I purchased to use with the site. The template uses jQuery to expand and collapse menu items in the left sidebar to show sub items [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in my <a href="http://www.tntechnohermit.com/2010/01/31/coldfusion-9-caching-settings-to-watch-out-for">last post</a>, I&#8217;m working on a pet project in my spare time. It uses <a href="http://www.jquery.com" target="_blank">jQuery</a> in various places including in the site design template that I purchased to use with the site. The template uses jQuery to expand and collapse menu items in the left sidebar to show sub items for that selection. Because of this, jQuery and a javascript file named custom.js was included in the template.  After breaking the template apart to work inside my <a href="http://www.model-glue.com" target="_blank">ModelGlue</a> application, I started implementing some other features that used jQuery with their own associated javascript files, one of which was <a href="http://cfuniform.riaforge.org" target="_blank">cfUniform</a>.</p>
<p>As soon as I put the cfUniform code into the page, I started getting javascript errors in the console pane of Firebug. The error would state something similar to &#8220;$(document) not a function&#8221; or &#8220;$ not a function&#8221;.  Now, I&#8217;ve not had a ton of experience with jQuery, but I have used several pre-built jQuery plugins in sites before and I had seen errors similar to this.  Normally this error is caused by one of two issues.  Either a) you&#8217;ve forgotten to include the script block to load the jQuery library or b) your code is loading the jQuery library twice.</p>
<p>I was able to use <a href="http://www.getfirebug.com" target="_blank">Firebug</a> to verify that I was indeed loading it and loading it only once but couldn&#8217;t for the life of me figure out why I was getting an error. Obviously cfUniform wasn&#8217;t really at fault (the error pointed to a line in one of the cfUniform javascript files) so I knew it had to be something on my side.  I did some searching on the phrase and found some discussions around jQuery&#8217;s noConflict() feature that allows you to reference jQuery with a notation other than using the familiar &#8220;$&#8221;.  </p>
<p>After reading for a while, I opened the custom.js file that came with the site template and found the code below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">noConflict</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #006600; font-style: italic;">//contents snipped</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Since I&#8217;m not using any other javascript libraries in this application that might conflict with using the &#8220;$&#8221; to access jQuery, I removed the noConflict() line, but that didn&#8217;t fix my problem. On a hunch I did a search/replace through the custom.js file replacing &#8220;jQuery(&#8221; with &#8220;$(&#8221; so that references to the jQuery library in this file would be accessed with the same syntax as in all the other javascript files. Lo and behold, all my errors in Firebug&#8217;s console went away and CFUniform began behaving as expected.</p>
<p>While I don&#8217;t understand all the underpinnings of why this worked, I&#8217;ll take it as my &#8220;lesson for the day&#8221; that in the future I need to always make sure that all the various jQuery plugins and code that is used in my applications need to reference the jQuery library with the same syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tntechnohermit.com/2010/02/01/jquery-head-scratcher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

