Move ID assignment into $.each loop (where it belongs)

c/o @nodesiremonk