Fix dashboard widgets issue, cache jQuery variables

Suggestion made in 77d42b508f37b2b55e53d607071593f2e1db9d1c by gavin19.