How to trap or catch onChange events from select or select2

How to trap or catch onChange events from select or select2

ekkerothekkeroth Posts: 19Questions: 6Answers: 0

How to react on a changed selection from a dropbox.
I tried to identify the id of the corresponding <select>, but the event is not fired.

$( "#DTE_Field_ltr_amounts-currencyid" ).on( "change", function() { alert('changed'); });

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Hi,

    The field().input() method will give you the select element which you can then bind the change event to:

    $( editor.field( 'myField' ).input() ).on( 'change', function () {
      console.log( 'select2 change' );
    } );
    

    Allan

This discussion has been closed.