I have a $(document).ready(function()
function on this page which fires successfully (so my javascript is loading successfully).
I am trying to fire an event when my select box is changed, but cannot get it to fire at all (even when I make it a click event). This is in Django Admin, so I cannot easily add an id
to the element (I'm sure it's not that difficult but I can't find how).
This is the element I'm trying to listen for:
<select name="base_module" required="" id="id_base_module">
These are a few things I've tried:
var test = document.querySelector('[name="base_module"]');
$(test).click(function(){
console.log("success")
});
$('#id_base_module').click(function(){
console.log("success")
});
$('select#id_base_module').change(function(){
console.log("success")
});
I've added my javascript file in my Django Admin page with this code under the correct model in the associated admin.py file:
class Media:
js = (
'js/javascript.js',
)
Any help setting an event listener on this element which will be fired when the item in the select box is changed would be appreciated.
Thank you.