I have an html template that I am using in my Django project. I have a string that is defined in my Django view that I want to pass to javascript in my html template, but I am having trouble getting it to work. There are two different strings, and the one displayed depends on the state of the toggle.
The strings created in my view (and when properly displayed) look like this:
ATS_string_true:
2015-123-01:34:39 CDS_FSW_FLASH_PLAYBK_STOP
2015-123-01:34:41 CDS_FSW_FLASH_REPLAY_REQ TLM_DATA_TYPE=0 START_BLOCK=7 NUM_BLOCKS=3
2015-123-01:34:43 CDS_FSW_FLASH_REPLAY_REQ TLM_DATA_TYPE=1 START_BLOCK=300 NUM_BLOCKS=12
2015-123-01:34:51 CDS_FSW_FLASH_PLAYBK_STOP
and ATS_string_false:
[Ref task: SAT_F7_COMM_NOMINAL_31_op ] 2015-123-01:34:39 CDS_FSW_FLASH_PLAYBK_STOP
However, the string in the error message looks like this:
[Ref task: <SAT_F7_COMM_NOMINAL_31_op> ] >> 2015-123-01:34:39 CDS_FSW_FLASH_PLAYBK_STOP
[Ref task: <SAT_F7_COMM_NOMINAL_31_op> ] >> 2015-123-01:34:41 CDS_FSW_FLASH_REPLAY_REQ TLM_DATA_TYPE=0 START_BLOCK=7 NUM_BLOCKS=3
[Ref task: <SAT_F7_COMM_NOMINAL_31_op> ] >> 2015-123-01:34:43 CDS_FSW_FLASH_REPLAY_REQ TLM_DATA_TYPE=1 START_BLOCK=300 NUM_BLOCKS=12
My html/js looks like this:
{% if ATS %}
<div class="panel panel-heading">
<h3 class="text-center">ATS</h3>
</div>
<div class="panel-body">
<div class="checkbox disabled">
<label>
<input id="ATS_debug" type="checkbox" data-toggle="toggle">
ATS Debug
</label>
</div>
<div id="ATS" style="background-color:black; color:white; padding:20px;">
<p>{{ ATS_string_false | linebreaks }}</p>
</div>
</div>
<script>
$(function() {
$('#ATS_debug').change(function() {
if ($(this).prop('checked')) {
$('#ATS').html({{ATS_string_true}});
} else {
$('#ATS').html({{ATS_string_false}});
}
})
})
</script>
{% endif %}
I'm getting an Uncaught SyntaxError: Unexpected identifier error at $('#ATS').html({{ATS_string_true}});. Can anyone help me out with this?
Thanks!