code: function () {
              var val, data = [], self=this;
  
              if (arguments.length === 0) {
                  return this.getVal();
              }
  
              val = arguments[0];
  
              if (!val) {
                  this.opts.element.val("");
                  this.updateSelection([]);
                  this.clearSearch();
                  return;
              }
  
              // val is a list of ids
              this.setVal(val);
  
              if (this.select) {
                  this.select.find(":selected").each(function () {
                      data.push({id: $(this).attr("value"), text: $(this).text()});
                  });
                  this.updateSelection(data);
              } else {
                  if (this.opts.initSelection === undefined) {
                      throw new Error("val() cannot be called if initSelection() is not defined")
                  }
  
                  this.opts.initSelection(this.opts.element, function(data){
                      var ids=$(data).map(self.id);
                      self.setVal(ids);
                      self.updateSelection(data);
                      self.clearSearch();
                  });
              }
              this.clearSearch();
          }
docs: multi