<?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>Web Development By George &#187; JavaScript</title>
	<atom:link href="http://www.webdevelopmentbygeorge.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webdevelopmentbygeorge.com</link>
	<description>ColdFusion, Flex, and JavaScript Programming</description>
	<lastBuildDate>Mon, 14 Nov 2011 20:45:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>CFAjaxProxy Problems or RTFM</title>
		<link>http://www.webdevelopmentbygeorge.com/2010/05/17/cfajaxproxy/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cfajaxproxy</link>
		<comments>http://www.webdevelopmentbygeorge.com/2010/05/17/cfajaxproxy/#comments</comments>
		<pubDate>Mon, 17 May 2010 19:24:20 +0000</pubDate>
		<dc:creator>George</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbygeorge.com/?p=211</guid>
		<description><![CDATA[So recently I&#8217;d been doing a cfselect box using bind to create my desired linked drop down.  The problem I was having was that I wanted to do a zebra stripe on the select after it had been loaded.  I could not find a way to attach the bind event to anything else so I [...]]]></description>
			<content:encoded><![CDATA[<p>So recently I&#8217;d been doing a cfselect box using bind to create my desired linked drop down.  The problem I was having was that I wanted to do a zebra stripe on the select after it had been loaded.  I could not find a way to attach the bind event to anything else so I couldn&#8217;t call a function after the bind had actually completed.  The way I wanted to solve this was to use a setTimeout on the coloring process.  The problem I was having was that my serializedJSON output I was using was no longer working.  It turns out &#8211; if you read the documentation &#8211; that using cfajaxproxy to pull in a CFC automatically serializes your output.  So if you&#8217;re returning a result of String with a serializeJSON(myQuery) you will end up with the data being DOUBLE SERIALIZED! Oh what a headache that was.  The proper way to do this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="js" style="font-family:monospace;">   &lt;cfajaxproxy cfc=&quot;myData&quot; jsclassname=&quot;myDataClass&quot; /&gt;
&nbsp;
   &lt;script&gt;
	getData = function(){
		var o = new myDataClass();
		var dataset = o.getData($('toggleField').checked);
		return dataset;
	}
   &lt;/script&gt;</pre></td></tr></table></div>

<p>Is to have your CFC do this</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfcomponent</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;getData&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;remote&quot;</span> returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;query&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;myToggle&quot;</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000FF;">required</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;yes&quot;</span> <span style="color: #0000FF;">default</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;false&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #000000; font-weight: bold;">var</span> qryData <span style="color: #0000FF;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
                <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfquery</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;qryData &quot;</span> <span style="color: #0000FF;">datasource</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;DATAS&quot;</span><span style="color: #0000FF;">&gt;</span></span>	
			SELECT *
                           FROM tableData
                <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfquery</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfreturn</span> qryData<span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfcomponent</span><span style="color: #0000FF;">&gt;</span></span></pre></td></tr></table></div>

<p>Rather than serializing it yourself first.  If you&#8217;re binding with a method of cfc: then you don&#8217;t need to do this, instead you need to change it to return text and use the SerializeJSON on your qryData query.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbygeorge.com/2010/05/17/cfajaxproxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>script.aculo.us Ajax Sortable Lists adjustment for ColdFusion</title>
		<link>http://www.webdevelopmentbygeorge.com/2010/04/16/script-aculo-us-ajax-sortable-lists-adjustment-for-coldfusion/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=script-aculo-us-ajax-sortable-lists-adjustment-for-coldfusion</link>
		<comments>http://www.webdevelopmentbygeorge.com/2010/04/16/script-aculo-us-ajax-sortable-lists-adjustment-for-coldfusion/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 13:57:07 +0000</pubDate>
		<dc:creator>George</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[script.aculo.us]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbygeorge.com/?p=199</guid>
		<description><![CDATA[So normally I&#8217;m a YUI guy. I enjoy their widgets and some of the other features available, and I&#8217;m comfortable with it. I work with several sites here that my co-workers work on, and they often prefer different JS Libraries. So I try to minimize the libraries on a site. Nothing more difficult, I feel, [...]]]></description>
			<content:encoded><![CDATA[<p>So normally I&#8217;m a YUI guy.  I enjoy their widgets and some of the other features available, and I&#8217;m comfortable with it.  I work with several sites here that my co-workers work on, and they often prefer different JS Libraries.  So I try to minimize the libraries on a site.  Nothing more difficult, I feel, when you&#8217;re maintaining a website and have to maintain YUI, jQuery, Dojo, and Script.aculo.us/Prototype all at the same time and with all of those libraries loading for a client!</p>
<p>So I had to repair something that wasn&#8217;t working in IE8 (imagine that <img src='http://www.webdevelopmentbygeorge.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) that was written quite some time ago.  The site had script.aculo.us/prototype on it so I wanted to stick with that library.  Thankfully, I came across this post:  <a href="http://zenofshen.com/posts/ajax-sortable-lists-tutorial">http://zenofshen.com/posts/ajax-sortable-lists-tutorial</a> and it&#8217;s a pretty handy layout for PHP and Script.aculo.us.  The problem arises at the bottom of the post.  In PHP, you would be fine using this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">parse_str</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'data'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>ColdFusion won&#8217;t parse out the string of <em>list_to_sort[]=2&#038;list_to_sort[]=1&#038;list_to_sort[]=3</em> like that though.  So I recommend making this adjustment to what&#8217;s coming through:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> newList <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">ListChangeDelims</span><span style="color: #0000FF;">&#40;</span>url.<span style="color: #0000FF;">data</span>, <span style="color: #009900;">&quot;|&quot;</span>, <span style="color: #009900;">&quot;list_to_sort[]=,&amp;list_to_sort[]=&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> sortPos <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">listLen</span><span style="color: #0000FF;">&#40;</span>newList, <span style="color: #009900;">&quot;|&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">list</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#newList#&quot;</span> delimiters<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;|&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;thisID&quot;</span><span style="color: #0000FF;">&gt;</span></span>
       <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfquery</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;insertSort&quot;</span> <span style="color: #0000FF;">datasource</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#request.source#&quot;</span><span style="color: #0000FF;">&gt;</span></span>
               INSERT INTO 'table' (listID, sortOrder)
                     VALUES (<span style="color: #0000FF;">#thisID#</span>, <span style="color: #0000FF;">#sortPos#</span>)
        <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfquery</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
        <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> sortPos <span style="color: #0000FF;">=</span> sortPos - <span style="color: #FF0000;">1</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbygeorge.com/2010/04/16/script-aculo-us-ajax-sortable-lists-adjustment-for-coldfusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YUI Loader &#8211; &#8220;other is undefined&#8221;</title>
		<link>http://www.webdevelopmentbygeorge.com/2009/04/20/yui-loader-other-is-undefined/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=yui-loader-other-is-undefined</link>
		<comments>http://www.webdevelopmentbygeorge.com/2009/04/20/yui-loader-other-is-undefined/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 19:37:47 +0000</pubDate>
		<dc:creator>George</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbygeorge.com/?p=61</guid>
		<description><![CDATA[So today I was getting the nice cryptic message of &#8220;other is undefined&#8221; when I was trying to call loader.require on an object.  Once I dug through my code I was trying to replicate from another section of the site, I realized that the details behind this was leaving out the loader.addModule section of code. [...]]]></description>
			<content:encoded><![CDATA[<p>So today I was getting the nice cryptic message of &#8220;other is undefined&#8221; when I was trying to call loader.require on an object.  Once I dug through my code I was trying to replicate from another section of the site, I realized that the details behind this was leaving out the loader.addModule section of code.  So if you come across this, take a look through your addModule sections to make sure you have all of the pieces you&#8217;re trying to add onto the code!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbygeorge.com/2009/04/20/yui-loader-other-is-undefined/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replacement for JavaScript Split</title>
		<link>http://www.webdevelopmentbygeorge.com/2009/04/20/replacement-for-javascript-split/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=replacement-for-javascript-split</link>
		<comments>http://www.webdevelopmentbygeorge.com/2009/04/20/replacement-for-javascript-split/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 15:41:34 +0000</pubDate>
		<dc:creator>George</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[cross browser]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[ie7]]></category>
		<category><![CDATA[split function]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbygeorge.com/?p=55</guid>
		<description><![CDATA[So the other day I was working on some JavaScript processing and it was working great in Firefox.  When I went to use it in IE7 it didn&#8217;t do a darn thing right.  I couldn&#8217;t figure out what was going on until somewhere I read that the Split function wasn&#8217;t the same in all browsers. [...]]]></description>
			<content:encoded><![CDATA[<p>So the other day I was working on some JavaScript processing and it was working great in Firefox.  When I went to use it in IE7 it didn&#8217;t do a darn thing right.  I couldn&#8217;t figure out what was going on until somewhere I read that the Split function wasn&#8217;t the same in all browsers.  That was one of those WTF moments for me, but after some digging I came across a script by <a href="http://blog.stevenlevithan.com/">Steve Levithan</a> that really does the job well.  Since that site is currently down, I&#8217;m including a copy of the file here for people: <a href="http://fairmontstudios.com/webdevbygeorge/wp-content/uploads/2009/04/newsplit.js">NewSplit.js</a>.  If you want to simply view and copy, here it is as well:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/*
Cross-Browser Split 0.3
By Steven Levithan &amp;lt;&lt;a href=&quot;http://stevenlevithan.com&quot;&gt;http://stevenlevithan.com&lt;/a&gt;&amp;gt;
MIT license
Provides a consistent cross-browser, ECMA-262 v3 compliant split method
*/</span>
&nbsp;
String.<span style="color: #660066;">prototype</span>._$$split <span style="color: #339933;">=</span> String.<span style="color: #660066;">prototype</span>._$$split <span style="color: #339933;">||</span> String.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">split</span><span style="color: #339933;">;</span>
&nbsp;
String.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">split</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>s <span style="color: #009966; font-style: italic;">/* separator */</span><span style="color: #339933;">,</span> limit<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// if separator is not a regex, use the native split method</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>s <span style="color: #000066; font-weight: bold;">instanceof</span> RegExp<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">return</span> String.<span style="color: #660066;">prototype</span>._$$split.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
varflags <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">global</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">&quot;g&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">ignoreCase</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">&quot;i&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">multiline</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">&quot;m&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
s2 <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;^&quot;</span> <span style="color: #339933;">+</span> s.<span style="color: #660066;">source</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;$&quot;</span><span style="color: #339933;">,</span> flags<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
output <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
origLastIndex <span style="color: #339933;">=</span> s.<span style="color: #660066;">lastIndex</span><span style="color: #339933;">,</span>
lastLastIndex <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> match<span style="color: #339933;">,</span> lastLength<span style="color: #339933;">;&lt;/</span>code<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/* behavior for limit: if it's...
- undefined: no limit
- NaN or zero: return an empty array
- a positive number: use limit after dropping any decimal
- a negative number: no limit
- other: type-convert, then use the above rules
&nbsp;
*/</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>limit <span style="color: #339933;">===</span> undefined <span style="color: #339933;">||</span> <span style="color: #339933;">+</span>limit <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
limit <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
limit <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">+</span>limit<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>limit<span style="color: #009900;">&#41;</span>
<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">global</span><span style="color: #009900;">&#41;</span>
s.<span style="color: #660066;">lastIndex</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">else</span>
s <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">source</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;g&quot;</span> <span style="color: #339933;">+</span> flags<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>limit <span style="color: #339933;">||</span> i<span style="color: #339933;">++</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> limit<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span>match <span style="color: #339933;">=</span> s.<span style="color: #660066;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> emptyMatch <span style="color: #339933;">=</span> <span style="color: #339933;">!</span>match<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Fix IE's infinite-loop-resistant but incorrect lastIndex</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>emptyMatch <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> s.<span style="color: #660066;">lastIndex</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> match.<span style="color: #660066;">index</span><span style="color: #009900;">&#41;</span>
s.<span style="color: #660066;">lastIndex</span><span style="color: #339933;">--;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">lastIndex</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> lastLastIndex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// Fix browsers whose exec methods don't consistently return undefined for non-participating capturing groups</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>match.<span style="color: #660066;">length</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
match<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span>s2<span style="color: #339933;">,</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: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> j <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> arguments.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>arguments<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">===</span> undefined<span style="color: #009900;">&#41;</span>
match<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
output <span style="color: #339933;">=</span> output.<span style="color: #660066;">concat</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span>lastLastIndex<span style="color: #339933;">,</span> match.<span style="color: #660066;">index</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> match.<span style="color: #660066;">length</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> match.<span style="color: #660066;">index</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span>
output <span style="color: #339933;">=</span> output.<span style="color: #660066;">concat</span><span style="color: #009900;">&#40;</span>match.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
lastLength <span style="color: #339933;">=</span> match<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// only needed if s.lastIndex === this.length</span>
lastLastIndex <span style="color: #339933;">=</span> s.<span style="color: #660066;">lastIndex</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>emptyMatch<span style="color: #009900;">&#41;</span>
s.<span style="color: #660066;">lastIndex</span><span style="color: #339933;">++;</span> <span style="color: #006600; font-style: italic;">// avoid an infinite loop</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// since this uses test(), output must be generated before restoring lastIndex</span>
output <span style="color: #339933;">=</span> lastLastIndex <span style="color: #339933;">===</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">?</span>
<span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">!</span>lastLength <span style="color: #339933;">?</span> output <span style="color: #339933;">:</span> output.<span style="color: #660066;">concat</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
<span style="color: #009900;">&#40;</span>limit <span style="color: #339933;">?</span> output <span style="color: #339933;">:</span> output.<span style="color: #660066;">concat</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span>lastLastIndex<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
s.<span style="color: #660066;">lastIndex</span> <span style="color: #339933;">=</span> origLastIndex<span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// only needed if s.global, else we're working with a copy of the regex</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">return</span> output<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbygeorge.com/2009/04/20/replacement-for-javascript-split/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>YUI Tab View &#8211; Getting the BeforeAction to work</title>
		<link>http://www.webdevelopmentbygeorge.com/2009/02/24/yui-tab-view-getting-the-beforeaction-to-work/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=yui-tab-view-getting-the-beforeaction-to-work</link>
		<comments>http://www.webdevelopmentbygeorge.com/2009/02/24/yui-tab-view-getting-the-beforeaction-to-work/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 15:49:14 +0000</pubDate>
		<dc:creator>George</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[YUI]]></category>
		<category><![CDATA[tab]]></category>
		<category><![CDATA[tabview]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbygeorge.com/?p=6</guid>
		<description><![CDATA[So I&#8217;ve been building a section of a website using the YUI TabView and having some difficulty getting the beforeActiveTabChangeevent to work right.  Now I was using version 2.5.2 first, and in that version, this event doesn&#8217;t even fire.  So I tried using beforeActiveChange on the tab itself.  I could get this to fire, but returning false as [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve been building a section of a website using the <a title="YUI TabView" href="http://developer.yahoo.com/yui/tabview/">YUI TabView</a> and having some difficulty getting the <em>beforeActiveTabChange</em>event to work right.  Now I was using version 2.5.2 first, and in that version, this event doesn&#8217;t even fire.  So I tried using <em>beforeActiveChange</em> on the tab itself.  I could get this to fire, but returning false as the documents say to do, would not stop the event from continuing.  So I did some digging, and found a post somewhere out there &#8211; I&#8217;ve lost it now &#8211; saying that 2.6 fixed this problem.  Well I tried that for a little while, and found that in 2.6, TabView&#8217;s <em>beforeActiveTabChange</em> does indeed fire, but it has the same problem that <em>beforeActiveChange</em> had in 2.5.2 &#8211; returning false does nothing.</p>
<p>Well as you can imagine, I found this to be frustrating.  So I started doing a little more digging &#8211; had a post on the YUI Developer boards go unanswered, googled a bunch of things &#8211; and then stumbled on to the face that 2.7 had been released.  Well I tried using that &#8211; figuring what the heck &#8211; and it worked! <em>beforeActiveTabChange</em> stopped the tabs from changing if false was returned!  Hallelujah!  Now I haven&#8217;t tried to see if <em>beforeActiveChange</em> at the tab level works now or not, but I&#8217;m just so happy to have the TabView event work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbygeorge.com/2009/02/24/yui-tab-view-getting-the-beforeaction-to-work/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

