mirror of
https://github.com/django-components/django-components.git
synced 2025-09-04 13:10:30 +00:00
🐛Prevent potential null elements
because {% component_js_dependencies %} loads all the components regardless
This commit is contained in:
parent
f5c3f64c86
commit
bb256f2ec8
2 changed files with 9 additions and 5 deletions
|
@ -220,7 +220,9 @@ Then you need a javascript file that specifies how you interact with this compon
|
||||||
```js
|
```js
|
||||||
/* In a file called [project root]/components/calendar/script.js */
|
/* In a file called [project root]/components/calendar/script.js */
|
||||||
(function(){
|
(function(){
|
||||||
document.querySelector(".calendar-component").onclick = function(){ alert("Clicked calendar!") }
|
if (document.querySelector(".calendar-component")) {
|
||||||
|
document.querySelector(".calendar-component").onclick = function(){ alert("Clicked calendar!"); };
|
||||||
|
}
|
||||||
})()
|
})()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
(function(){
|
(function(){
|
||||||
document.querySelector(".calendar-component").onclick = function(){alert("Clicked calendar!")}
|
if (document.querySelector(".calendar-component")) {
|
||||||
|
document.querySelector(".calendar-component").onclick = function(){ alert("Clicked calendar!"); };
|
||||||
|
}
|
||||||
})()
|
})()
|
Loading…
Add table
Add a link
Reference in a new issue