Skip to content

Jamie Wright Posts

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…

Exception handling in Web API 2

REST Web APIs are becoming more and more popular and have seen a large uptake recently. One of the nicer features that is available in the .NET web API 2 toolkit is it’s inbuilt exception handling. This allows you to maintain separation on concerns and stops controllers becoming bloated beasts of burden, or logging. A common scenario for people who have just started to build Web APIs is to blindly implement try-catch exception handling. This might look something like this As you can see, the actual code that performs the action that we want for this controller method is only…

Hello World!

Yes, I am probably not the first and nor will I be the last. However, I feel the title of a programmers first blog post is almost as certain as the first piece code he/she will ever write. I can’t escape the feeling that I would be disappointed to find out otherwise. Having spent a bit of time in the software industry now, I feel better equipped to give my opinions on various topics. I can hopefully provide help to people who might be struggling with a particular issue. (Hello all you frustrated googlers!) In this blog I will be…