title: How can I create unique id's for jQuery widget instances?
body: <p>I am creating a rich text editor based on jQuery widget, and it can have multiple instances on a page. The first instance should generate a toolbar like this:</p>
  
  <pre><code>&lt;input type="checkbox" id="bold-1"&gt;&lt;label for="bold-1"&gt;..
  &lt;input type="checkbox" id="italic-1"&gt;&lt;label for="italic-1"&gt;..
  ...
  </code></pre>
  
  <p>The second instance should generate:</p>
  
  <pre><code>&lt;input type="checkbox" id="bold-2"&gt;&lt;label for ="bold-2"&gt;..
  &lt;input type="checkbox" id="italic-2"&gt;&lt;label for ="italic-2"&gt;..
  </code></pre>
  
  <p>The labels 'for' attribute need to uniquely refer to their corresponding input 'id' attribute. Therefore I need to add a unique id for each instance.</p>
  
  <p>Something like this could work but I dont like to store a counter in global namespace:</p>
  
  <pre><code>var textEditorCount;
  $.widget("myEditor.textEditor", {
     _create: function () {
        textEditorCount = textEditorCount ? textEditorCount + 1 : 1;
        this.instanceID = textEditorCount;
     },
     ...
  };
  </code></pre>
  
  <p>Maybe the question boils down to: (How) can I store a variable in the namespace of the widget?</p>