IE8 select element change event not firing with the keyboard

Change events on select elements don’t fire in IE8 when the user confirms the selection with the enter key until the user clicks elsewhere. If your users are waiting on something in particular to happen after updating the select this is a bit of a problem. Here’s my solution: // jQuery syntax for ease of reading var the_select = $("#my_select"); // this works great for most browsers the_select.change(function() { console.log('changed'); }); // if IE8 if ($.browser.msie && parseInt($.browser.version, 10) <= 8) { // get the keypress event the_select.keypress(function(e) { // if the user pushed enter if(e.keyCode === $.ui.keyCode.ENTER) { // manually trigger the change handler $(this).change() // blur afterwards isn't ideal but // it doesn't work correctly otherwise .blur(); } }); }

July 11, 2013 · 1 min · Paul

Getting a particular superview in Objective-C

If you have, for example, a child view of a UITableViewCell and you need to get the UITableViewCell in question you can quickly do something like: UITableViewCell *cell = (UITableViewCell *)the_view.superview.superview; It works but this code is fragile because it requires that the view heirarchy not change (also things like this usually point to a code organization issue but hey, i’m not here to judge). If we want to be able to add a scrollview in between without editing this method we’ll have to take a different approach. ...

July 11, 2013 · 1 min · Paul

Debugging Javascript with Console

A quick review. Console.log() //how to print a log statement console.log('That thing you expected to happen is now happening!'); //how to break production sites in internet explorer console.log('anything'); //how to log safer function l(str){if(window.console&&console.log){console.log(str);}} l('I can forget this in my code base without breaking anything!'); Console.trace() //how to figure out what's calling what console.trace(); //console.trace example: function a() { console.trace(); } function b() { a(); } function c() { b(); } function d() { b(); } if (Math.random() < 0.5) { c(); } else { d(); } If you copy and paste that console.trace example into the Chrome Console you’ll get a full stack trace like this one: ...

July 9, 2013 · 1 min · Paul