ADM-dateTimePicker
ADM-dateTimePicker copied to clipboard
Ajax doesn't work with this datePicker
Hi, I use this datePicker in my project with angular and in the pages that I used this datePicker, Ajax doesn't work correctly. (An error occurred while attempting to process /system/ajax: this is undefined!) but in other pages, Ajax calls works correctly and when I remove this datePicker JS file from this pages the error will disappear and Ajax works fine.
please help me with this issue. thanks
I found this issue seems to be the result of this section of JS file ( Line 32 - 47 ):
Array.prototype.toNumber = function() { return this.map(function(item) {return Number(item);}); }; Array.prototype.dtp_toDate = function(type) { var splitter = '-'; if (/invalid/i.test(new Date('1991-9-12'))) splitter = '/'; var date = this.join(splitter); if (this.length == 5) date = this.slice(0,3).join(splitter) +' '+ this.slice(3,5).join(':') if (!type) return date; date = new Date(date); if (type == 'unix') return date.getTime(); return date; };
Fortunately, I found that "this" is undefined sometimes in this functions and I added an if statement before any "this" in this section of code and it works fine now.
thanks