Jump to content

ips.ui.autocomplete suggestion


CodingJungle

Recommended Posts

on the event "tokenAdded", could you also send the name of the autocomplete it came from? this way i can filter it in the listener. right now i have several on the page, and i'm checking each one to see if they have "tokens" to see which one it came from, so it would be much more efficient if i could do something like:

 

switch( data.tokenContainer ){
  case 'tokenContainer1':
    //do something
    break;
  case 'tokenContainer2':
    //do something else
    break;
}

 

Link to comment
Share on other sites

The event is triggered on the autocomplete element itself, so you should be able to determine which element it came from by using e.currentTarget or e.target (depending on how you set up your event handlers) 🙂

An example from one of our controllers:

initialize: function () {
    this.on( 'tokenAdded', '[data-ipsAutocomplete]', this.changeField );
},
  
changeField: function (e) {			
	var autocomplete = $( e.currentTarget );
}

 

Link to comment
Share on other sites

2 hours ago, Rikki said:

The event is triggered on the autocomplete element itself, so you should be able to determine which element it came from by using e.currentTarget or e.target (depending on how you set up your event handlers) 🙂

An example from one of our controllers:


initialize: function () {
    this.on( 'tokenAdded', '[data-ipsAutocomplete]', this.changeField );
},
  
changeField: function (e) {			
	var autocomplete = $( e.currentTarget );
}

 

i don't like this feeling...the shame it carries, that i have to admit @Rikki's javascript kung-fu is better than mine 😞 if any one needs me i'll be crying into my drink at some sleazy bar 😞 

just kidding, yeah it was definitely my methodology here, i was observing the document for my listener, $(document).on('tokenAdded', function(e, data){}); its why when i originally tried e.currentTarget it was giving me the document lol. 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...