existdissolve.com
the singularity of being and nothingness
the singularity of being and nothingness
May 3rd
So if you use Spry, you know that adding an eventListener to anything is super-simple. It's easy to add, and managing the processing that occurs on events is pretty intuitive.
For example:
Spry.Utils.addEventListener("myButton","click",doMyFunction,false);
This one line of code adds an eventListener to the element "myButton" for the onclick event, which will fire "doMyFunction()". And it's just as easy to remove the same eventListener:Spry.Utils.removeEventListener("myButton","click",doMyFunction,false);
Easy enough. However, I recently found myself wanting to not only add and remove eventListeners, but also to check if they exist for certain elements. Luckily, before digging into the DOM to much, I checked SpryDOMUtils.js–sure enough, there's a function already built for this.
In fact, as you may or may not be aware, you can run Spry.Utils.addEventListener() on an element as many times as you like–only one eventListener will be registered. This is because addEventListener() runs a check to see if the eventListener is already registered, and proceeds from there (look at line 166 in SpryDOMUtils.js v. 0.6 to see this in action).
So checking to see if an eventListener is registered for an element is exactly the same as adding and removing the eventListener. Here's what it looks like:
Spry.Utils.eventListenerIsBoundToElement("myButton,"click",doMyFunction,false);
This will return true or false, and you can do whatever you'd More >
May 2nd
Over the last year, I've learned alot about ColdFusion, AJAX, and DBA stuff. I have to say, however, that the coolest thing I've learned is that in ColdFusion 8 you can set per application mappings in the Application.cfc itself. Why is this so cool? Well, I tend to create a lot of folders in my applications in order to keep related assets in one place together. Of course, creating mappings to these folders makes life a lot easier in that you don't have to worry about making sure you are referencing these folders correctly in different contexts–with mappings ColdFusion can take of that for you.
However, the problem I often run into is that I have to create some funky mapping names in CF Administrator in order to keep them all unique. In my local host environment, for example, the number of mappings is huge and it becomes a hassel to remember to re-set these mappings up when I push final code to a production environment (not to mention that some hosting providers make doing this a lot harder than you could imagine…).
But with CF8, this is no longer a problem. Now you can create dynamic mappings in APplication.cfc, More >
May 1st
I recently created a little peice of functionality using Spry data to setup two lists that can swap data on the fly,
without the need for any postbacks to the server. I've done this thing several times before, but in the past, I've done it very inefficiently. Let me give you an example.
Let's say I'm building a list of songs to put on my mp3 player. I start with a list of all the songs from my media library, as well as a blank list that's waiting to be filled up with songs for the play list. In the past, what I've done is create two Spry data connections to a database, one to manage the play list, and one to manage the full list of songs.
Of course, this is easy enough to do, but I wanted to make it a bit better. For example, when selecting a song, I wanted to be able to show that the song was selected (and also make it un-selectable again).
My past approach would have been to start with an onclick event to handle the data saving. Once this process was complete, I would have fired a complete reload of both my More >
Apr 29th
Wow. It's been nearly 2 months since I last posted here. Not good.
The other night, I was feeling guilty about that, so I added a few items to my portfolio.
I've been out of commission the last several months for a couple reasons. First, my day job has been pretty hectic recently. We've been launching some large projects, and I've started to become involved a lot more with planning aspects of what we're doing. So while there's a lot less code work happening from me, I've been make up for that with writing, reviewing and an endless stream of meetings.
Second, I've been in the middle of a pretty decent little content management system. I'll be blogging about it a bit more when I'm ready to unveil it, but it's coming right along and I'm pretty pleased so far with what I've accomplished. As CMS's go, it's nothing revolutionary, but I have learned a ton in the process, so at least I have that going for me.
So in the meantime, I'm going to try to get back to blogging regularly. I've missed it quite a bit, and I have a ton of things to blog about, from opening up Spry's guts, More >
Apr 26th
(Thanks to Kevin for the inspiration!)
In Luke 10, Jesus tells the famous story of the Good Samaritan. In this narrative, the behavior of the Samaritan toward the injured man is juxtaposed with that of the a priest and a Levite to reveal the nature of the message of love which Jesus was teaching, a love which treats one's "neighbor" as oneself.
Obviously, the various facets of this story have been mulled over for countless centuries. However, while listening to a exposition of this passage this weekend, I was struck by something of an interesting idea: that the nature of love and generosity transcends morality.
Let me explain.
Generally, the attitudes of the Levite and priest are characterized quite pejoratively–after all, it is they who walked so callously by the injured man, with seemingly little regard for his life or injuries. While there is certainly a measure of truth to this characterization, I think some other considerations are warranted.
One of these considerations is that these men did not bypass the injured man out of gross neglect or comfortable apathy. In fact, it is quite possible that their hearts were moved to compassion. If this is so, why did they not then act?
Part of More >
Mar 1st
I've made clear in the past my great distaste for Microsoft Word and the "formatting" which it injects into WYSIWYG fields. I could write scores of pages about my dislike, but I'll let the following example speak for me. Keep in mind that the following is for 19 words.
<p><link href="file:///C:%5CDOCUME%7E1%5CDONVAN%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml" rel="File-List"><link href="file:///C:%5CDOCUME%7E1%5CDONVAN%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx" rel="themeData"><link href="file:///C:%5CDOCUME%7E1%5CDONVAN%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml" rel="colorSchemeMapping"><!--[if gte mso 9]><xml><w:WordDocument><w:View>Normal</w:View><w:Zoom>0</w:Zoom><w:TrackMoves /><w:TrackFormatting /><w:PunctuationKerning /><w:ValidateAgainstSchemas /><w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid><w:IgnoreMixedContent>false</w:IgnoreMixedContent><w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText><w:DoNotPromoteQF /><w:LidThemeOther>EN-US</w:LidThemeOther><w:LidThemeAsian>X-NONE</w:LidThemeAsian><w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript><w:Compatibility><w:BreakWrappedTables /><w:SnapToGridInCell /><w:WrapTextWithPunct /><w:UseAsianBreakRules /><w:DontGrowAutofit /><w:SplitPgBreakAndParaMark /><w:DontVertAlignCellWithSp /><w:DontBreakConstrainedForcedTables /><w:DontVertAlignInTxbx /><w:Word11KerningPairs /><w:CachedColBalance /></w:Compatibility><w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel><m:mathPr><m:mathFont m:val="Cambria Math" /><m:brkBin m:val="before" /><m:brkBinSub m:val="--" /><m:smallFrac m:val="off" /><m:dispDef /><m:lMargin m:val="0" /><m:rMargin m:val="0" /><m:defJc m:val="centerGroup" /><m:wrapIndent m:val="1440" /><m:intLim m:val="subSup" /><m:naryLim m:val="undOvr" /></m:mathPr></w:WordDocument></xml><![endif]--><!--[if gte mso 9]><xml><w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"DefSemiHidden="true" DefQFormat="false" DefPriority="99"LatentStyleCount="267"><w:LsdException Locked="false" Priority="0" SemiHidden="false"UnhideWhenUsed="false" QFormat="true" Name="Normal" /><w:LsdException Locked="false" Priority="9" SemiHidden="false"UnhideWhenUsed="false" QFormat="true" Name="heading 1" /><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" /><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" /><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" /><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" /><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" /><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" /><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" /><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" /><w:LsdException Locked="false" Priority="39" Name="toc 1" /><w:LsdException Locked="false" Priority="39" Name="toc 2" /><w:LsdException Locked="false" Priority="39" Name="toc 3" /><w:LsdException Locked="false" Priority="39" Name="toc 4" /><w:LsdException Locked="false" Priority="39" Name="toc 5" /><w:LsdException Locked="false" Priority="39" Name="toc 6" /><w:LsdException Locked="false" Priority="39" Name="toc 7" /><w:LsdException Locked="false" More >
Feb 5th
Another quick post 🙂
If you're using ColdFusion 8's datefield input AND are using a table for laying out the form, make sure that the cfform element is OUTSIDE of the table element.
This, of course, should be done anyway…however, tonight I was modifying some old, embarassing code and upgraded to the datefield. The page kept throwing an unhelpful JS error. After about 20 minutes of getting angry, I reversed the order of the table and form elements, and voila, it worked again.
Urgh.
Share this:Jan 27th
Just a quick post 🙂
I've been working on a pretty simple bit of code where one "row" of information is removed and added to a different table of information. Pretty simple stuff.
However, I ran into a issue with IE7 (go figure, right?). When using the "removeChild()" function, IE was not always removing the element specified. I debugged my code to no end, and couldn't find any issues.
Now I'm not sure if this is an actual bug, or an error in implementation on my part, but I ran across a post that seems to indicate that the best way to handle removeChild() in IE is to recursively remove all of the element's children, ending with the element itself (most other browsers don't seem to care, and just remove what you ask for!).
So really, I'm saying anything new, but just getting Google a bit more information to work with to other poor slobs looking for this answer.
Here's where I found the solution:
And here's the recursive function:
function removeChildSafe(el) { //before deleting el, recursively delete all of its children. while(el.childNodes.length > 0) { removeChildSafe(el.childNodes[el.childNodes.length-1]); } el.parentNode.removeChild(el);}
Share this:
Dec 23rd
I've written a couple of articles in the last few months about my adventures in JavaScript. While I certainly don't claim to be even proficient, I am getting better day by day. As I pick up tricks and tips, I try to pass them on to help others out (hopefully!).
Recently, we ran into an issue at work. We're constantly adding JavaScript functionality to our company intranet. While adding references to JavaScript files in the master pages that drive the templates is easy to do, there is a process that all master page changes have to go through, and this can limit the desirability of future changes. What we needed was a way to dynamically load JavaScript files when needed, so that only the core init.js file that is loaded with every page request needs to be referenced on the master pages.
I've never done this kind of thing before, so I did a little snooping around. There are apparently alot of solutions out there, some of them better and more robust than others. After studying what they do, I decided to try my hand at building a simple JS loader in Spry, given that the core files I need are More >
Dec 23rd
If you use one or more of the billion and seven content managment systems out there, you're probably more than familiar with a what-you-see-is-what-you-get (WYSIWYG) text editor. These *fun* little textareas allow users to mimic, with decent accuracy, the styles and organization that they would normally apply in word-processing documents.
The original intention of WYSIWYGs, of course, was to put control of text styling and organzation for web-based content into the hands of the people managing the content, so that every bit of text-editing doesn't have to go through the web developer. The result, however, is a disaster.
Why a disaster? Well, before discussing the reasons why, try this little experiment. The next time you're around a web designer/developer, say nothing to them. Simply shift your eyes, turn your head, and randomly blurt out "WYSIWYG!!!". They will either 1.) punch you in the mouth out of built up frustration or 2.) cower in a corner as they are reminded of how they are abused by WYSIWYGs on a daily basis.
So what's the big deal?
Well, to begin, most content managers have no business even thinking the word "design," much less actively participate in it. Giving them the reigns to "make the More >