{% extends '_includes/forms/autosuggest' %} {% block data %} {{ parent() }} data.senderClassValue = null; data.inputProps.onInputChange = this.myOnInputChange; {% endblock %} {% block methods %} {{ parent() }} updateSuggestions() { this.suggestions = []; if (this.senderClassValue) { Craft.postActionRequest('webhooks/webhooks/event-suggestions', { senderClass: this.senderClassValue }, $.proxy(function(response, textStatus) { if (textStatus === 'success') { this.suggestions = [ { data: response.events } ]; this.onInputChange(); } }, this)); } }, myOnInputChange(text) { // Has the Sender Class changed? if (this.senderClassValue !== (this.senderClassValue = $('#class').val())) { this.updateSuggestions(); } this.onInputChange(text); }, onSelected(option) { this.selected = option.item; // Trigger a 'change' event var input = this.$el.childNodes[0].childNodes[0]; jQuery(input).trigger('change'); }, {% endblock %}