Archive for the 'JavaScript' Category
How to Manually Trigger Events in JavaScript
Occasionally, I find need to be able to manually trigger a predefined JavaScript event from within the context of a web application. Those of you who didn’t understand that first statement may want to stop reading now or risk suffering from extreme boredom, but those who actually have encountered the same challenge in coding, please read on!
Let’s examine a possible scenario that could merit actually taking hold of the reigns on individual event calls. Consider the situation that you have devised a very user friendly data entry form, and in conjunction with specifications, you have a select box that triggers certain fields to be visible based on user selection. Typically, you would have simply attached a listener to the select box’s onchange event that checks the value of the field and performs the necessary showing and hiding. So far, we have done nothing difficult or out of the ordinary.
Now, suppose you also have need to be able to populate the form with a preexisting data set and get your form to behave in the same way. You could always write an onload listener for the body of your page that runs all the field checks and manipulates the fields accordingly, and in most cases, this may not be a poor solution. However, when loading dynamically via AJAX or other method, the onload event may not be triggered, and therefore, neither is your form updated.
Read more
jQuery Slideshow Plugin Update
I have finally found a few spare minutes to refactor the Google Code Project I started for my jQuery plugin last year. While I still am far from where I want to be with it, I have managed to set the plugin into a fully OOP codebase and add in events and the capability for custom handlers on those events. My hope is that people will now be able to find a bit more usability to the slideshow, since it is fully customizable. Feel free to swing by my Google Code page and let me know thoughts or ideas on ways to improve the slideshow as it evolves.
2 commentsJavaScript Library Nightly Builds, SymLinks and Auto-Updates
Something has been bothering me for some time, and I finally took the time to resolve the issue once and for all – relatively speaking. As mentioned in my previous post, I have had opportunity to work with multiple different JavaScript libraries, and I often find myself running behind on the newest bug fixes for a given module. Many of the library development teams offer a nightly build available to checkout via SVN or Git (usually by way of GitHub), and I devised a way to automatically update my shared repositories among all the domains on my server. While not rocket science, nor an entirely new idea to most of you, it is quite helpful to me, and I thought I’d share my method here.
There are actually four steps involved with this update, so I apologize in advance if this gets too long.
No commentsJavaScript libraries: jQuery vs. ExtJS
Often I have been asked which JavaScript library I prefer over all other, and the answer is not as easily orated as one might expect. Occasionally, I actually find someone willing to spend the time and thought involved with seeing the answer through to its conclusion. To avoid any undue future banter, I thought I would put my thoughts concerning the matter down in writing and simply reference this post when the topic is breached.
No, this will not be a comprehensive discussion and review of all available JavaScript libraries, but hopefully it will be sufficient to drive people to view the topic with a bit more of an open mind. Also, I must alert those who have come looking for a definitive answer from me: you will not receive a single library of choice here, but rather you will be given some insight to different perspectives requiring careful consideration when each library is being reviewed.
Read more
jQuery Plugin: gwSlideshow launched
A while ago, I wrote a jQuery based slideshow that I shared with some friends, and I ended up getting a pretty good response to it – enough to merit making a full plugin with it. Here is the initial launch of the plugin and project, and I’d love to get any feedback pertaining to usability and additional features.
The intent is to remain very lightweight but flexible, and so far, that seems to be met. Following, you will find links to my Google Code project page as well as a sample script that demos the working slideshow. For any additional questions, please feel free to contact me.
Google Code: http://code.google.com/p/gw-slideshow/
Demo: http://code.guahanweb.com/jquery/demos/gwSlideshow.html
Enjoy!
No commentsOptional Config Objects in JavaScript OOP
Well, one of the challenges in writing our custom JavaScript library for this next release of our CMS at work has been to come up with a modularized approach to our objects that can be followed precisely while still allowing a measure of flexibility to the end developer (Imagine that! Actually trying to support some framework style design principles in JavaScript!). Anyway, what has been one of the most challenging pieces to the puzzle has been to appropriately handle configuration objects passed to constructors that override specific, default behavior of the object.
No, the challenge was not so much handling a config object proper — that is relatively easy. Where the challenge began to really take shape was in allowing a user to provide specific pieces of optional data and only use the valid pieces of the config object to override existing default values while ignoring the rest so as not to cause any JavaScript errors to be thrown elsewhere in the script. For a quick example, let’s say we have the following data object that loads itself up using an Ajax call (NOTE: all examples in this post are using the ExtJS lib).
Read more
The Importance of a First Impression in Web
We all have heard the saying that You never get a second chance to make a first impression, and just as much as in our personal relationships, the brutal force of this statement shows itself true in the web world as well. I cannot count the number of times I have visited a website to glean information about a particular topic only to be immediately bombarded with any number of issues: from broken links to JavaScript errors, layout issues due to lack of attention given to cross browser compatibility, and even, in some cases, the dreaded 404 error right from the home page. Now, none of these issues is a deal breaker to me; I mean, come on, we’re all human, right?
Well, what if that website happens to be for a company or product that is in a technology industry to some varying degree? Does that make a difference? Based on some feelers I’ve put out over the years both with clients and customers for many of the projects of which I have been part, this can indeed make all the difference in the world. Whether or not your organization or product is web related, the average user hints at the fact that, if your content is perceived to be technology based in any form, these small faux pas mentioned above take on an impact of much greater magnitude.
Read more
Writing a Reusable AJAX Handler
Due to the number of questions I receive on various forums as well as the number of times I have run into the need for an AJAX response handler in my own work, I decided I would share one of my solutions in the hopes that it will save someone else some time as well. I assume, if you are reading this, that you have a basic knowledge of AJAX and the principles guiding the technology. In addition, basic understanding of how libraries such as jQuery perform AJAX queries and callback functions in JavaScript is a plus. For further reading on these prerequisites, check out this Google search and the jQuery docs.
After manually handling my responses in multiple projects, I finally decided to write a JavaScript object that could handle the XML responses for me and return me a usable object to my callback function. Enter the AJAX Handler object. I decided to let jQuery handle the actual requests for me, but I wanted a way to easily parse out my response, checking for errors and handle them accordingly. The result was something I have been able to use numerous times in different projects. To simplify things, let’s look at the code a piece at a time. At the bottom of this post, you will find the entire code. Read more
No commentsGoogle Resources Abound!
I have always been a fan of Google’s products as I have been made aware of them, and on very few occasions have I had anything negative to say about them. I recently have started using yet another assistance provided by Google that is, in my opinion, one of the single most helpful and creative tools to be offered free of charge to the development community. I speak of none other than the Google Web Toolkit. This Java application allows you to build quite extensive
On Internet and Gaming
Well, those of you who know me in the least are aware of my passion for video games. I have, quite literally, been a fan of console and PC gaming for as long as I can remember. My parents will vouch for the fact that, on my fifth birthday — before I could read — I was situated in front of our living room TV set with our TI-99/4A on my lap, an open code book next to me, pecking character by character until I had basic animations appearing on the screen. I vaguely remember those details, although I can remember playing games like Parsec and Hunt the Wumpus, but the passion for gaming is still there to this day.
My focus, however, has shifted from simply being a placid gamer to wanting to delve more into the inner workings of the game development process and the gaming industry in general. Choosing web development as a career path has given me more of an insight into the principles that make games work, and I greatly admire those with the knowledge and fortitude to stick with it during the grueling development process, but I still have that burning desire to be more actively involved in the industry in some way.
Read more