title: Programmatically selecting radios in jQuery buttonset makes it break down
body: <p>I'm building an editor function on a website using a jQuery buttonset based on radio buttons. When I load the item into the editor I need to set the selected radio button and then, of course, the user can change the option and it get's saved into the database. When the item closes I want to reset the buttonset to default.</p>
  
  <p>Problem is that when I set the buttonset it works the first time I select each item then it breaks down and stops working all together.</p>
  
  <p>Demo of problem: <a href="http://jsfiddle.net/kallsbo/vSmjb/" rel="noreferrer">http://jsfiddle.net/kallsbo/vSmjb/</a></p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div id="dumpSec"&gt;
      &lt;input type="radio" name="security" id="r_public" value="public" class="rSec"&gt;
      &lt;label for="r_public"&gt;&lt;i class="icon-globe"&gt;&lt;/i&gt; Public&lt;/label&gt;
      &lt;input type="radio" name="security" id="r_private" value="private" class="rSec"&gt;
      &lt;label for="r_private"&gt;&lt;i class="icon-lock"&gt;&lt;/i&gt; Private&lt;/label&gt;
      &lt;input type="radio" name="security" id="r_link" value="link" class="rSec"&gt;
      &lt;label for="r_link"&gt;&lt;i class="icon-link"&gt;&lt;/i&gt; Anyone with the link&lt;/label&gt;
  &lt;/div&gt;
  &lt;div&gt;
      If you use the buttons below you can programmatically select each of the radios in the buttonset once before it all breaks down...
  &lt;/div&gt;
  &lt;div&gt;
       &lt;button id="nbr1"&gt;Select Private&lt;/button&gt;&lt;br/&gt;
       &lt;button id="nbr2"&gt;Select Link&lt;/button&gt;&lt;br/&gt;
       &lt;button id="nbr3"&gt;Select Public&lt;/button&gt;&lt;br/&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>// Basic function
  $("#dumpSec").buttonset();
  $("#r_public").attr("checked", true);
  $("#dumpSec").buttonset('refresh');
  
  // Put in functions on the demo buttons
  $( "#nbr1" )
    .button()
    .click(function( event ) {
      $("#r_private").attr("checked", true);
      $("#dumpSec").buttonset('refresh');
    });
  
  $( "#nbr2" )
    .button()
    .click(function( event ) {
      $("#r_link").attr("checked", true);
      $("#dumpSec").buttonset('refresh');
    });
  
  $( "#nbr3" )
    .button()
    .click(function( event ) {
      $("#r_public").attr("checked", true);
      $("#dumpSec").buttonset('refresh');
    });
  </code></pre>
  
  <p>I have tried a number of things like trying to trigger the click function of the label for each radio button and so on but I can't find anything that works. Any input is appreciated!</p>