This does not work: http://jsfiddle.net/08bdzkwz/1/ This does: http://jsfiddle.net/08bdzkwz/2/ This is probably due to the wrong initialization order.