move all events from template to view class