ADM-dateTimePicker icon indicating copy to clipboard operation
ADM-dateTimePicker copied to clipboard

Ajax doesn't work with this datePicker

Open mshahrokhi opened this issue 6 years ago • 2 comments

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

mshahrokhi avatar Jul 31 '18 12:07 mshahrokhi

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; };

mshahrokhi avatar Aug 01 '18 04:08 mshahrokhi

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

mshahrokhi avatar Aug 01 '18 10:08 mshahrokhi