I'm not really sure what your question is, but usually this much juggling with ID-s is contraproductive, especially when you use a library with a very strong selector engine.
function addChangeEvents(selector) {
//all your elements are in the selector, why bother with mapping them to an other array like object?
selector.change(function () {
var $this = $(this); //this is the element the change event is fired on
selector.each(function () { //selector is the "list" of all elements
//you can access all the elements of the selector
console.log(this); //here this is the element you are iterating over.
console.log(this.id);
console.log($this); //you can access the $this variable defied in the outer function
});
});
}
And you can call it like:
addChangeEvents($('#filter select'));
The variable selector will contain all the elements you need. Also it will be available even after the addChangeEvents code executed (in the callback of the change event).
Does this answer your question?
EDIT:
Or perhaps you were mapping because there are more than one list of selects:
<div id="filter">
<select id="s1"/>
<select id="s2"/>
<select id="s3"/>
</div>
<div id="other_filter">
<select id="s4"/>
<select id="s5"/>
<select id="s6"/>
</div>
etc...
In this case you can call the addChangeEvents function more than once:
addChangeEvents($('#filter select'));
addChangeEvents($('#filter2 select'));
You can even iterate through all the filters if you add a class like:
<div id="filter" class="filter">
<select id="s1"/>
<select id="s2"/>
<select id="s3"/>
</div>
<div id="filter2" class="filter">
<select id="s4"/>
<select id="s5"/>
<select id="s6"/>
</div>
<div id="filter3" class="filter">
<select id="s7"/>
<select id="s8"/>
<select id="s9"/>
</div>
And than select the elements with the given class:
$('.filter').each(function () {
addChangeEvents($(this).find('select'));
});
<div>containing the<select>-s, and then find all the selects inside, not bothering with their IDs? It seems to me that you could get away with only static js.Filterfunction an API. Can you clarify your question on what you want?