I'm working on a Django project in which I used render_to_string to pre-render HTML templates from the backend, and then I send them to the frontend as a response to an ajax call.
rendered_html.append(
[render_to_string("webapp/popup.html", context=shop_context), location['Logo'], location['LONG'],
location['LAT'], location['id']])
return JsonResponse({"rendered_html": rendered_html})
I am appending this rendered_html into the frontend with javascript. The HTML code and the Django context variable work fine but the javascript in the file does not work at all. If I see the elements section from the developer's console, I can see that javascript is included but it does not work, not even a small console.log works.
Is there a workaround to this or am I doing something wrong? Any help will be appreciated.