Generalize the ajax-filter pre-selection code