title: Jquery select2 json data with optgroup and images
body: <p>I am using select2 with spring mvc. I got the data from my controller that I need to display here in terms of options. But I want them to be grouped as optgroup and also I want images to be appended in it which can be inserted manually as given below : - </p>
  
  <pre><code> &lt;optgroup label="group"&gt;
      &lt;option value="imageName"&gt;value 1&lt;/option&gt;
      &lt;option value="imageName"&gt;value 1&lt;/option&gt;
      &lt;/optgroup&gt;
  </code></pre>
  
  <p>Where imageName is the name of image. I want to :
  1)  Group options in json.
  2)  Provide this image attribute in json so that select2 can form the data.</p>
  
  <p>Here is the code : </p>
  
  <pre><code>$("#my-select").select2({
          data : [ {
              id : 0,
              text : 'enhancement'
          }, {
              id : 1,
              text : 'bug'
          }, {
              id : 2,
              text : 'duplicate'
          }, {
              id : 3,
              text : 'invalid'
          }, {
              id : 4,
              text : 'wontfix'
          } ]
      });
  </code></pre>
  
  <p>I am creating my json manually from my objects. So I can provide any data here. Any suggestions ?</p>