title: Change Dynamic field of Typeahead
body: <p>I'm programming a form with dynamic typeaheads fields, and i have found a problem when i want to show and select the suggestions.
  I have two first fields, a input select and a input typeahead. When a option is selected, it's load a list of values in the input typeahead. The problem comes when i create(dynamically) a clone of this pair of fields and i want to get de list of values in the correct typeahead. 
  I get the id of the field (idTypeAhead) when i focus in the field and i use it in the typeahead.
  This is the code:</p>
  
  <pre><code>//TYPEAHEAD 
  $('input.typeahead').focus(function(){
      idTypeAhead = parseInt($(this).attr('id').replace('typeAhead_',''));
      selectAttr = $('select#selectAttr_'+idTypeAhead).find('option:selected').val();
      if(selectAttr=="null"){
          selectAttr=0;
      }       
  });
  
  $("input#typeAhead_"+idTypeAhead).on("typeahead:select").typeahead({
          name:'input#typeAhead_'+idTypeAhead,
          displayKey: 'input#typeAhead_'+idTypeAhead,
          input: 'input#typeAhead_'+idTypeAhead,
          container:'input#typeAhead_'+idTypeAhead,
          display: $(this),
          suggestion: $(this),
          minLength : 1, 
          sorter : this.query,
          source : function(query, process){
              return $.ajax({
              url:'/aplicaciones/jsonValorAttr?selectAttr='+selectAttr,
              dataType: 'json',
              type:'POST',
              success: function(data){                    
                  states = [];     
                  map = {};  
                $.each(data, function (i, state) {         
                      map[state] = state;         
                      states.push(state); 
                      });       
              process(states);
              }
            });
          }
        });
  </code></pre>
  
  <p>I have this code in form (i use Spring STS). Also i have two buttons "+" and "-". When i click "+", i clone this two fields and increase de id number of each element. When i click "-", i remove a pair of fields. (example: selectAttr_101 ->newclone: selectAttr_102). </p>
  
  <pre><code>&lt;div class="controls"&gt;
          &lt;form:select path="rolHerramientaID" id="selectAttr_101" cssClass="field-required lstAtributos" cssErrorClass="select-error"&gt;
          &lt;form:option value="null" selected=""&gt;&lt;spring:message code="altaAplicacion.form.seleccionar" /&gt;
          &lt;/form:option&gt;
          &lt;c:forEach var="selectAtributos" items="${resultAtributos}" varStatus="rowCount"&gt;
          &lt;form:option value="${selectAtributos.atributosId}"&gt;${selectAtributos.nombreAtributo}&lt;/form:option&gt;
          &lt;/c:forEach&gt;
          &lt;/form:select&gt;
          &lt;form:errors path="rolHerramientaID" class="help-block" /&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="control-group required"&gt;
          &lt;label for="input01" class="control-label"&gt;&lt;spring:message code="altaAplicacion.form.valor" /&gt;&lt;/label&gt;
          &lt;div class="controls"&gt;
          &lt;input id="typeAhead_101" class="input-medium typeahead" type="text"  data-provide="typeahead" autocomplete="on"&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>How can i change the container of the typeahead dynamically?</p>