<?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>Seagull Code Nodes &#187; jQuery</title>
	<atom:link href="http://blog.joshuasiegal.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.joshuasiegal.com</link>
	<description></description>
	<lastBuildDate>Tue, 05 Oct 2010 06:25:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Rel Isn&#8217;t That Nice</title>
		<link>https://blog.joshuasiegal.com/2010/rel-isnt-that-nice/</link>
		<comments>https://blog.joshuasiegal.com/2010/rel-isnt-that-nice/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 17:44:25 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[semantic]]></category>

		<guid isPermaLink="false">http://blog.joshuasiegal.com/?p=202</guid>
		<description><![CDATA[Just a quick post to talk about how much I&#8217;m loving the rel tag these days.   Defining custom values for this attribute may not be strictly validated, but there seems to be some debate about this, and with HTML 5, we&#8217;re going to be moving that way with the all-encompassing data- tag. But for now, [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick post to talk about how much I&#8217;m loving the rel tag these days.   Defining custom values for this attribute may not be strictly validated, but there seems to be some debate about this, and with HTML 5, we&#8217;re going to be moving that way with the all-encompassing <a title="The HTML5 data tag" href="http://www.danwebb.net/2010/1/27/put-that-data-attribute-away-son-you-might-hurt-someone" target="_blank">data-</a> tag.</p>
<p>But for now, the rel tag is easy, supported, and makes getting a little bit of meta information to your script quite easy.</p>
<p>Two uses I&#8217;ve written recently are:</p>
<p>(1) Creating abstracted div collapse scripts.  The script just looks at the rel tag for the link and finds the matching rel tag among a class of divs on the page.  Anything matching is shown, anything not matching is hidden.  I never have to go back and touch the script, and I only have to add a rel tag to my divs.</p>
<p>(2) Letting my css-based navigation know which page we&#8217;re currently on.  With includes, the idea that your navigation should reflect your current page location fell out of favor a bit.  Kind of suspicious, if you ask me.  It often seems designers and front-end developers adapt their pet styles to suit the latest technology.  Regardless, it&#8217;s dang easy with the rel tag to revert to the &#8220;old&#8221; style of location-aware navigation.  I just drop a rel tag in my nav links and a matching rel tag in my content div within the content include file.  They search for each other.  They find one another.  It&#8217;s like an interface component romance paperback.</p>
<p>Part of the reason that HTML 5 is going to include some developer-defined tags is that people have been using rel and a few other tags to include meta data (and sometimes some not-so-meta data) in their front-end code.  I completely understand the cold chill that comes over some folks when they start contemplating gobs of data gooping up the front end.  I also think it&#8217;s possible to fret too much.  As the linked article above points out well, it&#8217;s possible to include some meta data inline and still be semantically useful, degrade nicely, and not offend the browser.</p>
<p>If people hadn&#8217;t been expanding on the uses of the rel attribute so effectively, we may not have had the push for user-defined attributes in HTML 5.  This is a good thing.  It&#8217;s important to remember this truism: no amount of standards will stop people from writing ugly code.  But, paying attention to what developers are doing in practice and honoring those practices in new standards definitions can benefit everyone.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.joshuasiegal.com/2010/rel-isnt-that-nice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sufferin Semantics! XML, HTML, jQuery, and MSIE</title>
		<link>https://blog.joshuasiegal.com/2010/sufferin-semantics-xml-html-jquery-msie/</link>
		<comments>https://blog.joshuasiegal.com/2010/sufferin-semantics-xml-html-jquery-msie/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 22:54:32 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[semantic]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.joshuasiegal.com/?p=168</guid>
		<description><![CDATA[So, in a recent project, I&#8217;m consuming xml data and pulling out some text for a description field on an html page.  I&#8217;ve got some basic stuff, text for title information, paths to asset files stored as node attributes, the usual.  But something is bugging me.  I&#8217;ve included some html in my descriptions, all formatted [...]]]></description>
			<content:encoded><![CDATA[<p>So, in a recent project, I&#8217;m consuming xml data and pulling out some text for a description field on an html page.  I&#8217;ve got some basic stuff, text for title information, paths to asset files stored as node attributes, the usual.  But something is bugging me.  I&#8217;ve included some html in my descriptions, all formatted according to xhtml standards, but it won&#8217;t be parsed by jQuery.</p>
<p>Dagnabit!  What is the point of combining xml and html standards if I can&#8217;t use them together all the time?  I know, you may be thinking, but xml is not html , no matter what you throw into your nodes.  You&#8217;re right, and this is exactly what jQuery tells us.  You can grab the text contents of any node, but if you have html tags in there, the <a title="jQuery API - text method" href="http://api.jquery.com/text/" target="_blank">.text()</a> method in jQuery will just look right past them.  As it should.  This works fine, for little snippets like my titles, but what if I want to put some (ostensibly) well-formatted html code in my data?  Further, what about all those applications where you want to store html snips in a database and read them out in XML?  How do you get around this?</p>
<p><span id="more-168"></span></p>
<p>For that, we&#8217;d want to use the <a title="jQuery API - html method" href="http://api.jquery.com/html/" target="_blank">.html()</a> method of jQuery, and for that, my friends, we suddenly get quite strict.  XML, according to jQuery, is not html, and so has no innerHTML quality for the .html() method to grab.  It doesn&#8217;t matter, says jQuery, if your html code is so well formatted that it can be parsed as xml&#8230;it&#8217;s just not possible to access an html-specific property that does not exist.</p>
<p>Like fun, I say!</p>
<p>But before we get to the solution, let&#8217;s heartlessly go over some available options:</p>
<p>1) We could punt on the whole jQuery thing and use Flash, which knows just what to do with a string of html parsed from within an xml node.  Furthermore, Flash has a nifty .htmlText property on its text fields, and although the formatting of said html pales compared to real css, it will faithfully render as html anything you tell it to, caveat codeur.  Since the project in question did involve some Flash, this was an option, but one of the points of the project was to take the same xml data and have both flash and jQuery parse it for different purposes, and thereby provide ease for content providers and improve accessibility.  So doing the whole thing in Flash was out.</p>
<p>2) We could escape the heck out of all our characters and turn the whole node into a mess of html character codes.  Un-fun to code and messy for the content people.  Also, I tried that and it rendered out a block of actual html onto my screen.  I&#8217;m sure I could have reconverted those characters back into actual html behind the scenes, but again, un-fun and a hassle.</p>
<p>3) Use a fancy xml consuming plugin or script.  There are some neat ones out there, and I tried one in particular that looked pretty good, but it seems they have a common issue &#8211; you have to know what tags you&#8217;re looking for in order to seek and replace within the script.  Some of them will hunt for anything that looks like an html tag in the string and convert that, but mostly these plugins seem like scripts that people wrote to perform functions for themselves, and then extracted and shared.  Which I applaud.  But these were not what I was looking for, and I found the implementation sometimes troublesome.</p>
<p>4)<strong> [Warning: bad solution]</strong> Hand jQuery a bag of grapes and say it&#8217;s &#8220;nature&#8217;s jellybeans&#8221; (at least that&#8217;s what my mom used to do to us).  It goes like so: grab your xml file with an <a title="jQuery API - ajax method" href="http://api.jquery.com/jQuery.ajax/" target="_blank">ajax()</a> call, and use the optional key/value pair:</p>
<blockquote><p>dataType: &#8220;html&#8221;</p></blockquote>
<p>And then you&#8217;d do ike so:</p>
<blockquote><p>$.ajax({ url: &#8220;myXMLdoc.xml&#8221;,<br />
dataType: &#8220;html&#8221;,<br />
success: function(xml){<br />
var myHtmlContent = $(&#8216;node&#8217;,xml).eq(id).find(&#8220;nodeName&#8221;).html();<br />
$(&#8220;#targetdiv&#8221;).html(myHtmlContent);<br />
}<br />
});</p></blockquote>
<p>&#8230;and there you have it!  Or, would&#8230;if&#8230;</p>
<p>&#8230;can you see where this is going?</p>
<p>&#8230;search your feelings, Luke&#8230;</p>
<p>&#8230;if only Internet Explorer handled the XMLHTTPRequest result like the rest of the world!  Like most Microsoft stuff, IE, with its <strong>own</strong> version of the XMLHTTPRequest (someone <a title="Microsoft XMLHTTPRequest documentation" href="http://msdn.microsoft.com/en-us/library/ms535874%28VS.85%29.aspx" target="_blank">correct me if I&#8217;m wrong on that</a>), wants to get too clever and won&#8217;t let you, the developer, tell it what kind of data you&#8217;d like to see (even if it&#8217;s either of several types that are verging toward common standard).  No siree!</p>
<p>Supposedly, recent versions of IE (7+) have their own XMLHTTPRequest, not the previous Microsoft HTTPRequest.  However, the Microsoft XMLHTTPRequest doesn&#8217;t behave like the other girls and boys, even in the recent versions of IE.  Now, this post didn&#8217;t start off to be a discussion of the supposed evils of Microsoft&#8217;s proprietary habits.  But who else has almost 11 million results on a <a title="google search: internet explorer sucks" href="http://www.google.com/#hl=en&amp;q=internet+explorer+sucks&amp;aq=f&amp;aqi=&amp;oq=&amp;fp=c26c79a56c95bda8" target="_blank">google search of how much they suck</a>?  Hint: not Chrome (3 M), Firefox (1 M), or Safari (1 M).  (Can&#8217;t evaluate Opera on this critrion because sadly a lot of people out there think that real, actual opera &#8211; the music &#8211; sucks too).  For comparison: &#8220;yanni sucks&#8221; (400 K), &#8220;death metal sucks&#8221; (700 K), &#8220;paris hilton sucks&#8221; (1 M), &#8220;the lions suck&#8221; (1 M), &#8220;tv sucks&#8221; (11 M), and &#8220;new york sucks&#8221; (12 M).  So, yeah.</p>
<p>Anyway, after that turgid digression, <em>finally,</em> we come to the solution.  And&#8230;</p>
<p>It&#8217;s simple!  Maybe I&#8217;m, like, the last one to figure this out, but you just use XML&#8217;s <a title="W3C XML CDATA" href="http://www.w3schools.com/XML/xml_cdata.asp" target="_blank">CDATA</a> declaration, and wrap it around our html code within our xml node.  If I had found that idea earlier, it would have saved me some time, but I would have missed a brain-scratching moment or ten for sure.</p>
<p>Anyway, this is fascinating to me for several reasons:</p>
<p>a) When oh when is Microsoft going to just give up and give us a truly standards-compliant web browser?  Maybe they should spin off a company whose software is intuitive and flexible and plays nice with others.  Oh wait, <a title="apple" href="http://www.apple.com/" target="_blank">they already did that</a>.</p>
<p>b) With the XHTML standard in full force, it seems totally silly that one would have to pass off perfectly valid XHTML within an xml document as CDATA.  Isn&#8217;t the whole point of XHTML to be able to one day have a semantic web, where code itself can be meaningful?  How far away are we when it&#8217;s trouble to get even well-formatted html out of my xml nodes without basically commenting it out?  In theory, that means I can&#8217;t parse through my html elements, which seems to go against the whole ethos of XHMTL.</p>
<p>Well, heck.  I remember when CSS was going to put an end to bad code.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.joshuasiegal.com/2010/sufferin-semantics-xml-html-jquery-msie/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
