F
F
filmincer2016-05-16 23:52:26
JavaScript
filmincer, 2016-05-16 23:52:26

How to properly insert Django templatetag into jquery code?

Hello.
I use bootstrap-datepicker, I want the selected dates to be unselectable, for this I pass the list of busy dates (in the correct date format) to the datesDisabled: [] option using the template tag

<script>
  $(document).ready(function(){
    $(function() {
        $('#sandbox-container .input-daterange').datepicker({
        format: "yyyy-mm-dd",
        orientation: "bottom auto",
        language: "ru",
        datesDisabled: {{ car.get_date }},
                                templates: {
            leftArrow: '<i class="fa fa-arrow-left"></i>',
            rightArrow: '<i class="fa fa-arrow-right"></i>'
        }
        
      });
    });
  });
</script>

...after which all the jquery code on the page (even those not related to this functionality) stops working.

Tried it like this:
datesDisabled: [{{ car.get_date }}],

the result is still the same!

it seems to me that the jungian {{ }} tag is generally impossible to insert into JS code by default without breaking it.

Question: why? Or how can I get around this problem?
I would be very happy for any help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Sklyar, 2016-05-17
@VladSkliar

Try to create a list earlier
And then pass the list inside the function
Probably the joke is that you close the function prematurely with symbols }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question