I would prefer to have this as a class instead a simply function so you could store the $(#layout) element and could be easily tested with jasmine.