Jquery click a href link inside for loop
<p>I have assigned a variable with arrays inside array i.e.</p>

<pre><code>var encounter_names = new Array();
encounters.encountersDB.each(function(encounter) { encounter_names.push(new Array(encounter.key, encounter.name))})
</code></pre>

<p>this is my for loop statement mentioned as below</p>

<pre><code>for (var i = 0; i &lt; encounter_names.length; i++) {
    window['li' + i] = $("li[key='" + encounter_names[i][0] + "']")
    window['li' + i] = $("&lt;li key='" + encounter_names[i][0] + "' class='list'&gt;&lt;a class='arrow_'+ encounter_names[i][0] +'" + encounter_names[i][0] + "' href='#'&gt;" + encounter_names[i][1] + "&lt;/a&gt;&lt;/li&gt;")
    $('.arrow_' + encounter_names[i][0] + '').click(function (event) {
        encounters.show(window['key' + i]);
        event.preventDefault();
    })
    encounters_list.append(encounter_names[i][0])
}
</code></pre>

<p>When I click an href link I am get the following error in console log:  </p>

<pre>TypeError: Result of expression 'encounter_names[i]' [undefined] is not an object.</pre>

<p>Any suggestions are always welcomed.</p>
