Possible to get {% block myblock %} in js? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Possible to get {% block myblock %} in js?

I use a django template with eg {% block myblock %} Can I get that block as an element in js? Eg. var myblock = ??? myblock.html(newHtml)

31st May 2022, 1:56 PM
Fu Foy
Fu Foy - avatar
5 Answers
+ 1
No its not possible but why don't you directly access it with id of a div. You can put you django block in a div and assign a id to div and use it in your js. And django variable are meant for server to render the page, I don't think it has any relation with js.
9th Jun 2022, 2:15 PM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 1
AKSHAY🇮🇳 its not actually an issue. I was just curious
9th Jun 2022, 4:23 PM
Fu Foy
Fu Foy - avatar
31st May 2022, 3:00 PM
Justice
Justice - avatar
0
https://code.sololearn.com/WseuLrO5LaXB/?ref=app
31st May 2022, 3:12 PM
Calviղ
Calviղ - avatar
0
Justice thank you, but I think the answer is only about how to get django vars in js.
31st May 2022, 7:06 PM
Fu Foy
Fu Foy - avatar