two-scoops-of-django-3.x
two-scoops-of-django-3.x copied to clipboard
Typo in Example 19.1
Location within the Book
Example 19.1: Properly JSON encoding Data for JavaScript
In version 3x-07-08-alpha
Description
I think the param of json_script "page-data" needs to match getElementById('page')
Possible Solutions
Change getElementById param to 'page-data'
{{ page_data|json_script:"page-data" }}
<script>
var data = JSON.parse(document.getElementById('page-data').textContent);
injectNameIntoDiv('scoopName', data.scoop.name);
</script>
Your full name so we can provide accurate credit within the book
John Carter