$apply() to the rescue.