Converting template into jquery elements