Skip to content

Tag: jquery

Javascript custom event handling in IE

Events can be extremely useful in Javascript, and most browsers implement them naively. Here is an example of an event that fires when the number of vehicles change. This will work on every single browser, except IE. It even works on edge.  If you run this in IE 11 or lower you will receive an “Object does not support this action error”.  To get around this there are two options. JQuery or using a polyfill. For simplicity, cross browser support and the general pervasiveness of JQuery, the first approach is generally the best approach.  You can implement the equivalent above…

Coding standards in Javascript

This is more of a plea than a post, but I would like to impress upon you something important. When it comes to Javascript, please do not throw everything you know about good OO practice out the window! Javascript has gained a bit of a reputation for being misused. It is almost understandable, as it is so easy to do things that you know you really shouldn’t. Oh look, a shortcut! Bad idea. When you come back to try and untangle this shortcut later, you end up with a patchwork of dependencies. The whole thing becomes a nightmare. Once you…