Support

Account

Home Forums Backend Issues (wp-admin) List of JS hooks Reply To: List of JS hooks

  • Looks like there’s been an update because now you can just do this. I took this from their API documentation page. You can change the selectors in this to do whatever you want, the code below will fire two events, one for all inputs on change the other specifically for text input types.

    var instance = new acf.Model({
        events: {
            'change': 'onChange',
            'change input[type="text"]': 'onChangeText',
        },
        onChange: function(e, $el){
            e.preventDefault();
            var val = $el.val();
            // do something
        },
        onChangeText: function(e, $el){
            // do something for just text inputs and then call the normal change callback
            this.onChange(e, $el);
        }
    });