moved jquery code from controller to directive