JS refactring added callback to detail emplate