[Answered ]-Javascript and django app / boilerplate integration

1đź‘Ť

âś…

Finally it works,

the problem is the attr()

According to this post jquery select all checkboxes

in jQuery 1.6 and above, prop() should be used for “checked” status instead of attr() with true or false being passed

Finally the working code was

$("#selectAll").change(function() {
   $(".checkbox_delete:checkbox").prop('checked', this.checked);
});
👤Pablo V.

1đź‘Ť

$(".checkbox_delete:checkbox").attr('checked', $(this).attr('checked));

Try with this

0đź‘Ť

The only thing wrong in your code that I can find is the following:

$(".checkbox_delete:checkbox").attr('checked', this.checked);

this should be

$(".checkbox_delete[type="checkbox"]").attr('checked', this.checked);

NOTE

[type="checkbox"] won’t be needed if you have good classnames and don’t use the .checkbox_delete on radio’s etc.

Your original selector was not valid. You would have gotten errors logged into your console.

In firefox the shortcut for this is F12, If you don’t have firebug for FF / Chrome installed, I’d recommend you do so as it is an extremely good way of checking for JS errors, which usually ends in solving them as well.

👤SidOfc

Leave a comment