jQuery, AJAX and ATG

Posted on December 23, 2008 in Technology

While working on a large eCommerce project, we ran across a little issue.

The client chose ATG as their CMS platform and by default ATG chose the DOJO framework for thier base implimentations.

I am a personal fan of jQuery unobtrusive and standards compliant way of creating function documents albeit I have not played with DOJO a ton, but it just does not seem completely unobtrusive with its specific tagging system.

I wrote a few pages which had specific AJAX functionality which it needed to call upon data from ATG and the requests were getting mis-handled by the form handler on the ATG side.

We took a working DOJO prototype and compared the headers. It seems like the jQuery serialize() function was ignoring the inputs which had a type of submit, this is something the ATG form handler was looking for.

I quickly re-prototyped the serialize function to include the submit buttons and wallah.

In case you want to see the new serialize function I have included it below. Hope this helps someone else out as it took me a few days to figure this one out.

Cheers and Happy Holidays to all.

$.fn.serializeArray = function() {
return this.map(function(){
return jQuery.nodeName(this, "form") ?
jQuery.makeArray(this.elements) : this;
})
.filter(function(){
return this.name && !this.disabled &&
(this.checked || /select|textarea/i.test(this.nodeName) ||
/text|hidden|submit|password/i.test(this.type));
})
.map(function(i, elem){
var val = jQuery(this).val();
return val == null ? null :
val.constructor == Array ?
jQuery.map( val, function(val, i){
return {name: elem.name, value: val};
}) :
{name: elem.name, value: val};
}).get();
}

[ There are no comments yet, be the first to add a comment ]

Fun with the javascript date object.

Posted on July 10, 2008 in Technology

So for a few projects recently I needed to make use of Javascript Date functionality. At first glance it seems like this archaic system of creating and managing dates but after some tinkering I am realizing yet again that tools created in the computer dawn of time are unbelievably robust.

One of the issues I keep running into is when taking a date which you are working with and trying to make a copy of a date object, when you modify the date of the clone the original is affected. That’s because it’s a reference and not a clone. Watch out for this as I was bit a few times.

var date1 = new Date(“07/05/08”) var myDate = date1; //this creates a reference to the original myDate.setDate(“15”); date1.getDate(); //equals 15

Some other cool things that you can do with the date object is that you can very easily add days to a date, and it will calculate if months change, leap years etc.

myDate.setDate(myDate.getDate() + 10) // adds 10 days.

You can also subtract two dates from each other.

christmas = new Date(“12/25/08”); today – new Date(); secondsToChristmas = christmas – today; //time to christmas in milliseconds daysToChristmas = secondsToChristmas /(1000*60*60*24); //yey math is fun!

[ view comments (1) | Add your comment ]

Rusty

Posted on March 25, 2008 in Sports
Update: They turned it around in classic Sox fashion, the boys are back in town. woot.

It's a little after 6:30 in the AM. I am not sure WHY exactly but I find myself on my couch watching the Red Sox 2007 home opener.

The Red Sox look super rusty -- that could be due to the fact that they are not even done with spring training yet! I can't tell you the reasoning for having the Red Sox play two official games in Japan before returning back to the US and playing 3 more spring training games but none the less they (especially Matsuzaka) look completely uninspired.

I think they Yankees had a similar schedule a few years back when they did their tour of Japan and that caused them to get off to a very slow start -- hopefully this does not repeat itself.

It's only the bottom of the 2nd inning (bases loaded) so hopefully they will turn things around.

[ There are no comments yet, be the first to add a comment ]

About your Author

This site is owned and operated by Eric Webster. A designer/developer in the Boston area and these are the rantings and ravings of daily life.

For more information visit the About section

Previously

Twitter Updates

    My Del.icio.us Links