title: Jquery Select 2 not showing selected value
body: <p>Select2 plugin is not showing selected option with templateFormat option
  Anyone knows how fix it ?</p>
  
  <p>markup:</p>
  
  <pre><code>&lt;select id="plans" style="width: 75%"&gt;
  &lt;option value="1" name="text1" price="$1" saving="text" selected="selected"&gt;&lt;/option&gt;
  &lt;option value="2" name="text2" price="$2" saving="text" selected="selected"&gt;&lt;/option&gt;
  </code></pre>
  
  <p></p>
  
  <p>js:</p>
  
  <pre><code>$(document).ready(function() { 
   $('select#plans').select2({
     minimumResultsForSearch: Infinity,
     templateResult: formatState
  });
  });
  function formatState(state) {
  if (!state.id) return state.text;
  var html = '&lt;span class="name"&gt;' + state.element.attributes.name.value + "&lt;/span&gt;"
  html += '&lt;span class="price"&gt;' + state.element.attributes.price.value + &lt;/span&gt;"
  html += '&lt;span class="saving"&gt;' + state.element.attributes.saving.value + "&lt;/span&gt;"
  var $state = $(html);
  return $state
  }
  </code></pre>
  
  <p>here is a <a href="https://jsfiddle.net/ed0pL2sd/" rel="nofollow">fiddle</a> of the above code</p>
  
  <p>Thank you</p>