title: jquery plugin method return value not object
body: <p>I wrote a jq-plugin where I first want to init the selected elements (all of them-each).
  Later in the code I want to get a string produced by a method. But all it returns are the objects but not my string.</p>
  
  <p>i did a lot of research on the internet but i don't know how to make the plugin 'chainable' on the one hand and 'returning any values' on the other hand.</p>
  
  <p>what do you think?</p>
  
  <pre><code>(function($){
      var methods = {
          init: function(val){
              // Actions to initialize ALL selected Elements
          }
          ,
          returner: function(val){
              alert('working with every selected element: '+$(this).width());
              // return anything
              return 'STRING PRODUCED BY THIS FUNCTION!';
          }
      }
  
      $.fn.myplug = function(method){
          var args = arguments;
          var init = 'init-myplug';
          return this.each(function(){
              var is_init = $(this).data(init);
              if (is_init &amp;&amp; methods[method]){
                  return methods[method].apply($(this), Array.prototype.slice.call(args, 1));
              } else if (!is_init &amp;&amp; (typeof method === 'object' || !method)){
                  $(this).data(init, true);
                  return methods.init.apply($(this), Array.prototype.slice.call(args, 0));
              }
          });
      };
  })(jQuery);
  
  $('.selects_5_elements').myplug(); // init
  
  $('.selects_5_elements').myplug('returner'); // get the string
  </code></pre>