jQuery, AJAX and ATG
Posted on December 23, 2008 in TechnologyWhile 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 ]

RSS (2.0)