Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
CodingJungle Posted January 31, 2019 Posted January 31, 2019 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; }
Rikki Posted February 1, 2019 Posted February 1, 2019 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 ); }
maddog107_merged Posted February 1, 2019 Posted February 1, 2019 Is it possible to autocomplete the search bar? Like google where it predicts what you are typing?
CodingJungle Posted February 1, 2019 Author Posted February 1, 2019 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.