title: Ajax star rating resets when focus lost (jquery)
body: <p>I am using following code for AJAX rating system</p>
  
  <pre><code>jQuery.fn.rater = function(url, options)
  {
      if(url == null) return;
      var settings = {
          url       : url, // post changes to 
          maxvalue  : 5,   // max number of stars
          curvalue  : 0    // number of selected stars
      };
  
      if(options) { jQuery.extend(settings, options); };
      jQuery.extend(settings, {cancel: (settings.maxvalue &gt; 1) ? true : false});
  
      var container = jQuery(this);
      jQuery.extend(container, { averageRating: settings.curvalue, url: settings.url });
  
      var raterwidth = settings.maxvalue * 25;
      var ratingparent = '&lt;ul class="star-rating" style="width:'+raterwidth+'px"&gt;';
  
      container.append(ratingparent);
  
      // create rater
      var starWidth, starIndex, listitems = '';
      var curvalueWidth = Math.floor(100 / settings.maxvalue * settings.curvalue);
      for(var i = 0; i &lt;= settings.maxvalue ; i++) {
          if (i == 0) {
              listitems+='&lt;li class="current-rating" style="width:'+curvalueWidth+'%;"&gt;'+settings.curvalue+'/'+settings.maxvalue+'&lt;/li&gt;';
          } else {
              starWidth = Math.floor(100 / settings.maxvalue * i);
              starIndex = (settings.maxvalue - i) + 2;
              listitems+='&lt;li class="star"&gt;&lt;a href="#'+i+'" title="'+i+'/'+settings.maxvalue +'" style="width:'+starWidth+'%;z-index:'+starIndex+'"&gt;'+i+'&lt;/a&gt;&lt;/li&gt;';
          }
      }
      container.find('.star-rating').append(listitems); // i am using find here, because the span wrapped in the small style would break children()
  
      if(settings.maxvalue &gt; 1) // add a container for the ajax result
      {
          container.append('&lt;span class="star-rating-result"&gt;&lt;/span&gt;'); 
      }
      var stars = jQuery(container).find('.star-rating').children('.star');
      stars.click(function()
      {
          if(settings.maxvalue == 1) // on / off
          {
              settings.curvalue = (settings.curvalue == 0) ? 1 : 0;
              jQuery(container).find('.star-rating').children('.current-rating').css({width:(settings.curvalue*100)+'%'});
              jQuery.post(container.url, { "rating": settings.curvalue });
  
              return false;
          }
          else
          {
  
              settings.curvalue = stars.index(this) + 1;
              raterValue = jQuery(this).children('a')[0].href.split('#')[1];
              jQuery.post(container.url, { "rating": raterValue }, function(response){
                  container.children('.star-rating-result').html(response)    
              });
              return false;
          }
          return true;
      });
  
      return this; 
  }
  </code></pre>
  
  <p>The problem is that when I click on something else other than stars, rating reset itself. </p>
  
  <p><strong>Could you suggest some ways to make the rating retain its value, when the focus is lost?</strong></p>