Added `callback` as third parameter of jQuery.fn.render

The goal is to be able to chain after async `ajax` operation is completed and after template has been applied.

- added a third parameter `callback` to `$.fn.render`
- checked if `callback` is a function and executed the same in scope of the selection

Since we were repeating same work in two places, moved the event trigger code to a single closured function called `applyTemplate`.