return $(form).hasClass('crm-ajax-selection-form');
}
+ // Use ajax to store selection server-side
function phoneHome(single, $el, event) {
var url = CRM.url('civicrm/ajax/markSelection');
var params = {qfKey: 'civicrm search ' + $('input[name=qfKey]', form).val()};
params.name = $el.attr('id');
} else {
params.variableType = 'multiple';
+ // "Reset all" button
if ($el.is('a')) {
event.preventDefault();
$("input.select-row, input.select-rows", form).prop('checked', false).closest('tr').removeClass('crm-row-selected');
- } else {
+ }
+ // Master checkbox
+ else {
params.name = $('input.select-row').map(function() {return $(this).attr('id')}).get().join('-');
}
}
.on('crmLoad', function(e) {
if ($(e.target).is('#crm-container') || $(e.target).is('#crm-main-content-wrapper')) {
clearTaskMenu();
- selected = usesAjax() ? parseInt($('label[for*=ts_sel] span', form).text(), 10) : countCheckboxes();
+ if (usesAjax()) {
+ selected = parseInt($('label[for*=ts_sel] span', form).text(), 10);
+ } else {
+ selected = countCheckboxes();
+ displayCount();
+ }
enableTaskMenu();
}
})
<script type="text/javascript">
{literal}
CRM.$(function($) {
+ // Clear any old selection that may be lingering in quickform
$("input.select-row, input.select-rows", 'form.crm-search-form').prop('checked', false);
+ // Retrieve stored checkboxes
var cids = {/literal}{$selectedContactIds|@json_encode}{literal};
if (cids.length > 0) {
- $('#mark_x_' + cids.join(',#mark_x_')).prop('checked', true).closest('tr').addClass('crm-row-selected');
- $('input[name=radio_ts][value=ts_sel]').prop('checked', true);
+ $('#mark_x_' + cids.join(',#mark_x_') + ',input[name=radio_ts][value=ts_sel]').prop('checked', true);
}
});
{/literal}