title: JavaScript: Public methods and prototypes
body: <p>I'm not entirely sure how to implement OOP concepts in JS.</p>
  
  <p>I have a class which is entirely declared in its constructor:</p>
  
  <pre><code>function AjaxList(settings)
  {
  
      // all these vars are of dubious necessity... could probably just use `settings` directly
      var _jq_choice_selector = settings['choice_selector'];
      var _jq_chosen_list = settings['chosen_list'];
      var _cb_onRefresh = settings['on_refresh'];
      var _url_all_choices = settings['url_choices'];
      var _url_chosen = settings['url_chosen'];
      var _url_delete_format = settings['url_delete_format'];
  
      var jq_choice_selector_form = _jq_choice_selector.closest("form");
      if (DEBUG &amp;&amp; jq_choice_selector_form.length != 1)
      {
          throw("There was an error selecting the form for the choice selector.");
      }
  
      function refresh()
      {
          _updateChoicesSelector();
          _updateChosenList();
          _cb_onRefresh();
      };
  
      AjaxList.prototype.refresh = refresh; // will this be called on all AjaxLists, or just the instance used to call it?
      // AjaxList.refresh = refresh; // will this be called on all AjaxLists, or just the instance used to call it?
  
      // ...
  }
  </code></pre>
  
  <p>There are multiple instances of AjaxList. When I call <code>refresh()</code> on one of them, I want only that one list to refresh itself. In the following instance:</p>
  
  <pre><code>term_list = AjaxList(settings);
  term_list.refresh();
  </code></pre>
  
  <p>The <code>refresh()</code> call seems to make all the AjaxLists refresh themselves. What is the correct way to do this?</p>
  
  <p>I'm using jQuery, if it makes any difference.</p>