title: Generate JQuery reference by generated HTML on event fire
body: <p>I have a web application I'm working on.  One facet of it supports the sending of messages.  Recently I've decided the user needs the ability to send files in their message.</p>
  
  <p>TMI probably, but... I have a hidden input type=file, when the user clicks the image icon I fire trigger.  The user gets local file browser dialog, once a file is selected, I pass the file data via ajax, store the file and generate a link in a content editable div.  This is all working fine.</p>
  
  <p>Here's the rub:
  My anchor generated has title='' and then in JQuery I want to say:</p>
  
  <pre><code>$('id').tooltip({content: '&lt;img src="" /&gt;'})
  </code></pre>
  
  <p>I'd like to have it work so when the user hovers over the anchor, a thumbnail of the uploaded image is displayed, but I am not sure how to 'put' the generated jquery out for use in my script.  That seems silly, but I just can't get my head around it.</p>
  
  <p>Here's some code:</p>
  
  <p>Once local file browse dialog is closed I catch event/grab data like so:</p>
  
  <pre><code>$('#file').on('change', function() {
              file_upload = $(this)[0].files[0];
              var data = new FormData();
              data.append('function', 'file_upload');
              data.append('file_upload', file_upload);
              $.ajax({
                      url: 'ajax_send_message.php',
                      data: data,
                      cache: false,
                      contentType: false,
                      processData: false,
                      type: 'POST',
                      success: function(data) {
                              if (data) {
                                      alert(data);
                              }
                      }
              });     
              var image_path = "path/to/file/&lt;?=$member_id?&gt;/"+file_upload.name;
              var image = "&lt;a id='"+file_upload.name+"' href='"+image_path+"' title=''&gt;Edit this text&lt;/a&gt;";
              var body = $('#msg_body').html();
              body += image;
              $('#msg_body').html(body);
              $( "#"+file_upload.name+"" ).tooltip({ content: '&lt;img src="'+image_path+'" /&gt;' });
      });
  </code></pre>
  
  <p>Specifically, I'm not sure how to get this puppy out in the wild or tie it to something</p>
  
  <pre><code>$( "#"+file_upload.name+"" ).tooltip({ content: '&lt;img src="'+image_path+'" /&gt;' });
  </code></pre>
  
  <p>Thanks in advance for the help!</p>