How to add custom change event to a select

How to add custom change event to a select

INTONEINTONE Posts: 153Questions: 58Answers: 6
edited October 2014 in Editor

I have tried doing this to trigger a change event for a select that was created by editor but nothing happens. What am I doing wrong:

$("#DTE_Field_forms.case_id").change(function(){
alert("I was tapped");
});

This question has an accepted answers - jump to answer

Answers

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

    Unfortunately there is a bug in Editor at the moment when the field name contains a . when the name is applied to the ID which makes it unelectable.

    The workaround is to use the Editor API field().node():

     $('select', editor.field('forms.case_id').node()).change(function(){ alert("I was tapped"); });
    

    The bug will be fixed in 1.4.

    Allan

  • INTONEINTONE Posts: 153Questions: 58Answers: 6
    edited October 2014

    Thank you for your response. When I tried it I however got this error:

    Uncaught TypeError: Object forms.case_id has no method 'node'

    Any idea how this can be resolved.

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

    Sorry - typo in my code above. I've corrected it now. Just a missing bracket.

    Allan

  • INTONEINTONE Posts: 153Questions: 58Answers: 6

    Thank you this does work.

This discussion has been closed.