Field Notes

Make Use of What You Have

November 19, 2014 | In 30 days

The corollary to changing layers when something is difficult is to use what you have when you can.

Today I excavated a byzantine chunk of javascript. The code calls an Angular service which used jQuery to jam a fragment into the DOM and compile it so the Angular view can call a directive that randomizes the order of options in a drop down.

I feel like I spent the day chasing Carmen Sandiego.

Instead I'm going to randomize the options before handing them to ng-select. Underscore's _.sample function works nicely. It's already included in the project, so it can replace the homemade array shuffler. No touching the DOM outside of a view. No extra directive.