two-scoops-of-django-3.x icon indicating copy to clipboard operation
two-scoops-of-django-3.x copied to clipboard

Typo in Example 19.1

Open therefromhere opened this issue 2 years ago • 0 comments

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

therefromhere avatar Aug 18 '21 04:08 therefromhere