Lists - uncheck all checkboxes

Hello,

I couldn’t find on how to uncheck all checkboxes in a _list_toolbar.htm controller with JS.

I genereate a PDF to download with some data of the list entries and after the generation of the PDF I want to disable the delete entries button and I want everything to be unchecked again:

function handleDownloadPdfSuccess(data, textStatus, jqXHR) {
    if (jqXHR.deleteJobPdf) {
        // try to disable delete button with added class (doesn't work)
        $('.toolbar-button-delete').attr('disabled', true);

        //  try to uncheck head checkbox and all list checkboxes  (doesn't work)
        $('.control-list').listWidget('toggleHeadCheckbox');
        $('.control-list').listWidget('toggleChecked');

        //  disable PDF generate button and add link to PDF (works)
        $('#generate-delete-application').attr('disabled', true);
        $('#download-delete-application-pdf').removeAttr('disabled').attr('href', jqXHR.deleteJobPdf);
    } else {
        // TODO: make error flash
    }
}

I call handleDownloadPdfSuccess with a button data-request-success="handleDownloadPdfSuccess".

Someone knows how to do that?

window.location.reload(); 

doesnt help with this situation?

or

in your script in controller action

return $this->asExtension('ListController')->listRefresh();

Probably something like this

$('.control-list .list-checkbox input[type="checkbox"]')
    .prop('checked', false)
    .trigger('change');
1 Like