Core Javascript Object Date Fix
Core Javascript Object to Fix Date JSON AJAX Requests. When you call a date object in AJAX against .NET it will make the date "\/Date(...)\/". This fixes this to be a date object.
by cjgaudin
JavaScript
var mainObject = (function (mainObject, $, Modernizr, undefined) {
var core = mainObject .core = mainObject.core || {};
//---------------PUBLIC FUNCTIONS--------------------
core.initPage = function (scriptUrl) {
core.scriptUrl = scriptUrl;
$('#loadingContainer').ajaxStart(function () {
showLoadingContainer();
}).ajaxStop(function () {
hideLoadingContainer();
});
//-------------------AJAX JSON DATE FIX-------------------
$.ajaxSetup({
// Add a custom converter to convert ASP.NET JSON dates to JS Date object
// That is convert { "\/Date(...)\/" } to { new Date(...) }
// converters: {
// "text json": function (textValue) {
// return (new Function("return " + textValue.replace(/"\\\/Date\((.*?)\)\\\/"/g, "new Date($1)")))();
// }
// },
converters: {
"text json": function (data) {
//Need to use the jquery.extensions.js that overrides parseJSON
return $.parseJSON(data, true);
}
}
});
//---------------------------------------------------------
};
core.initHtml5Features = function () {
var cornerScript, jsonScript;
cornerScript = core.scriptUrl + 'jquery.corner.js';
jsonScript = core.scriptUrl + 'json2.js';
Modernizr.load([{
test: Modernizr.borderradius,
nope: { 'corner': cornerScript },
callback: {
'corner': function () {
//$('#menu a').corner('round top'); //Cant do this because it adds CC wrong
$('#footer').corner('round bottom 5px');
$('#loadingContainer').corner('round 15px');
}
}
}, {
test: typeof JSON !==...