wp_enqueue_scripts
, admin_enqueue_scripts
, or login_enqueue_scripts
hooks. This notice was triggered by the codepen-embed-script
handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/jwblogger/jwBlogger/wp-includes/functions.php on line 6114I’ve been playing with a massive Kendo UI Grid<\/a> for the past few months. I really enjoy Kendo UI – I can build functionality quickly, and the forums are very active and helpful. But there is so much grid I can take!!<\/p>\n I decided to take a break from my grid for a few days and familiarize myself with the Kendo UI Datepicker<\/a>. I gave myself a project to calculate the number of unbirthdays someone has had. So many people tell their age in the number of birthdays. Well, wouldn’t it be crazy if we all spoke our age in terms of unbirthdays? (These all the thoughts one has when they write lots of javascript and suffer from a lack of sunlight.)<\/p>\n Plus, today is the 34th anniversary of my first unbirthday!<\/p>\n See the Unbirthday Calculator at the bottom of this blog post.<\/strong><\/p>\n Despite the absurdity of the purpose of this project, these are my takeaways from this exercise:<\/p>\n Check out the code on Github.<\/a><\/p>\n To calculate unbirthdays, you first calculate the number of days in between today and your birth date, then subtract the number of birthdays. Here is what that looks like in javascript:<\/p>\n As with all the Kendo UI Widgets, there is ample examples<\/a> and documentation<\/a> provided by the Kendo UI Team.<\/p>\n One thing that stumped me is how to allow the user to type in a date, validate the input, then trigger the change event of the DatePicker. I was confused as to why I couldn’t trigger the change event of the DatePicker by typing in a value. This led me to implement a Validator<\/a>, as well as a ‘keyup’ event handler for when the user presses ‘Enter’ and submits their input. By wrapping my DatePicker in a Validator, and adding a ‘keyup’ event handler, I am able to allow the user to type in a value if they choose to.<\/p>\nQuick Takeaways<\/h3>\n
\n
The Code<\/h3>\n
Calculating Unbirthdays<\/h3>\n
var calcUnBirthday = function(bday, today) {\n\n\t\/\/get difference between two dates, in milliseconds\n\tvar diff = today.getTime() - bday.getTime();\n\n\t\/\/find age by converting difference into Date, then subtracting from 1970.\n\t\/\/ref: http:\/\/stackoverflow.com\/questions\/4060004\/calculate-age-in-javascript\n\tvar diffDate = new Date(diff);\n\tvar age = Math.abs(diffDate.getUTCFullYear() - 1970);\n\t\n\t\/\/calculate days since birthdate by converting the difference into days.\n\tvar daysSince = Math.ceil(diff \/ (1000 * 60 * 60 * 24));\n\n\t\/\/calculate unbirthdays\n\tvar unBirthdays = daysSince - age;\n\n\treturn unBirthdays;\n};\n<\/pre>\n
Working with the Kendo UI DatePicker<\/h3>\n