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);
});
1đź‘Ť
$(".checkbox_delete:checkbox").attr('checked', $(this).attr('checked));
Try with this
- [Answered ]-WSGIDaemonProcess does not affect python site
- [Answered ]-Django listener isn't hearing the signal
- [Answered ]-Unable to match trailing slash after email address in url regex
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.
- [Answered ]-Django queryset order by related model with distinct
- [Answered ]-How does Celery handle task failures within a chain?
- [Answered ]-Django: Admin template shows old values after page refresh
- [Answered ]-Django trying to split and urlify tags in models, but code isn't working
- [Answered ]-The "select all" header checkbox that I used in Django 1.5 is missing in Django 1.9