moving javascript for dynamically loaded to pages to dynamically loaded pages