// Once a filter has been chosen, rerender create links and refocus the search box
$el.select2('close');
$el.select2('open');
+ } else {
+ $('.crm-entityref-links', '#select2-drop').replaceWith(renderEntityRefCreateLinks($el));
}
})
.on('change.crmEntity', 'select.crm-entityref-filter-key', function() {
- var filter = $el.data('user-filter') || {};
- filter.key = $(this).val();
+ var filter = {key: $(this).val()};
$(this).toggleClass('active', !!filter.key);
$el.data('user-filter', filter);
loadEntityRefFilterOptions($el);
});
}
} else {
- $valField.hide();
+ $valField.hide().val('').change();
}
}