[Answered ]-Django jquery toggle in form from model

2👍

Try putting the jQuery event code inside an onload function, otherwise the form elements won’t exist yet in the dom and there is nothing for jQuery to query yet.

$(document).ready(function() {
    $("#id_allday").click(function () {
        $('#toggle').toggle("slow");
    })
}

Also, you may want to bind to change instead of click incase someone toggles the input with the spacebar instead of the mouse button.

Leave a comment