Multiple autocompletes on same form in socialengine

Posted by Mirza Awais on Stack Overflow See other posts from Stack Overflow or by Mirza Awais
Published on 2013-10-26T09:51:44Z Indexed on 2013/10/26 9:53 UTC
Read the original article Hit count: 351

Filed under:
|
|
|

I am quite new to socialegine module development. I want to use multiple autocomplets on my one form. I have no problem of showing multiple auto completes but problem comes when one selects options from auto complete.

I have seen that autocompet.js uses id toValues to show selected option from autocomlte. So if there is only one autocomplete on one form then we can have one element as toValues to show the selected value. But if we have multiple auto completes then how to show the selected item of each auto complete as separately? Using the following code for autocomplete

 en4.core.runonce.add(function() {

  new Autocompleter.Request.JSON('to', '<?php echo $this->url(array('module' => 'localspots', 'controller' => 'lookup', 'action' => 'city'), 'default', true) ?>', {
    'minLength': 2,
    'delay' : 1,
    'selectMode': 'pick',
    'autocompleteType': 'message',
    'multiple': false,
    'className': 'message-autosuggest',
    'filterSubset' : true,
    'tokenFormat' : 'object',
    'tokenValueKey' : 'label',
    'injectChoice': function(token){
      console.log(token.type);
      var choice = new Element('li', {'class': 'autocompleter-choices', 'html': token.photo, 'id':token.label});
      new Element('div', {'html': this.markQueryValue(token.label),'class': 'autocompleter-choice'}).inject(choice);
      this.addChoiceEvents(choice).inject(this.choices);
      choice.store('autocompleteChoice', token);
    },
    onPush : function(){
      if( $('toValues').value.split(',').length >= maxRecipients ){
        $('to').disabled = true;
        $('to').setAttribute("class", "disabled");     
      }
    },
  });

});

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery