title: jQuery Selector as Function Parameter
body: <p>In the following code I attempt to pass a jQuery listView selector to the function "makeObject" as a parameter. The problem I'm having is that the code doesn't recognize the .listview method of the selector in the function "createList".</p>
  
  <p>I'd like a solution that does simply pass in a string and reconstruct the selector inside 
  the called function.</p>
  
  <p></p>
  
  <pre><code>&lt;head&gt;
      &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
      &lt;script&gt;
          function Object() {
              this.selector;
              this.createList;
          }
  
          function makeObject(selector) {
              var result = new Object();
              result.selector = selector;
              result.createList = createList;
  
              return result;
          }
  
          function createList() {
              this.selector.append("&lt;li&gt;list item 1&lt;/li&gt;");
              this.selector.append("&lt;li&gt;list item 2&lt;/li&gt;");
              this.selector.append("&lt;li&gt;list item 3&lt;/li&gt;");
              this.selector.listview("refresh");
          }
  
          var selectorParam = $("#testList");
          var testObject = makeObject(selectorParam);
          testObject.createList();
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;ul id="testList" data-role="listview"&gt;&lt;/ul&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>