title: jQuery - programmatically create dynamic links
body: <p>I'm pretty new to jQuery and javaScript programming and wondered if anyone could help me?</p>
  
  <p>I have slider bar which is populated using an unordered list. Works very nicely, rendering text dynamically on top of button images. Each of this list items contains a link that calls a Function. For example:</p>
  
  <pre><code>&lt;li&gt;&lt;div class="btnGraphic"&gt;&lt;img src="images/button.png" /&gt;&lt;a href="#" id="my_link"&gt;&lt;div class="btnText"&gt;'MyTitle'&lt;/div&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;';
  </code></pre>
  
  <p>However I now wish to populate the entire page dynamically using and XML file. There will be no static content on the pages therefore the slider contents must be able to change and take a variable number of buttons and therefore links.
  I've retrieved the data from the XML file and stored it in a number of arrays. 
  The code for adding a list item now reads as follows:</p>
  
  <pre><code>for (i = 1; i &lt; count; i++) {
      var newListItem = '&lt;li&gt;&lt;div class="btnGraphic"&gt;&lt;img src="images/button.png" /&gt;&lt;a href="#" id="'+myLink[i]+'_link"&gt;&lt;div class="btnText"&gt;'+myTitle[i]+'&lt;/div&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;';
      $("#sliderList").append(newListItem);
  };
  </code></pre>
  
  <p>So far so good. I think. However where I'm unable to progress further is programmatically creating the link. The link opens a jQueryUI dialog box. The code for the link on the static page reads as follows:</p>
  
  <pre><code>$('#my_link').click(function(){
       clearScreen(); //clears any open dialog boxes
       $('.myContent').dialog('open');
       return false;
  });
  </code></pre>
  
  <p>My question to you is how do I create this code programmatically? The following is, I know absolutely not right and a long way off but it gives an idea of what i want to do:</p>
  
  <pre><code>for (i = 1; i &lt; count; i++) {
      $("'"+myLink[i]+"_link'").click(function() {
          clearScreen(); //clears any open dialog boxes
          $("'."+myContent[i]+"'").dialog.('open');
          return false;
      });
  };
  </code></pre>
  
  <p>I realise also that I may be approaching this from the wrong angle, so any pointers, help, etc very much gratefully received!</p>