Submit on listbox change

Submit on listbox change

dpanscikdpanscik Posts: 202Questions: 47Answers: 0

I'm trying to submit form on listbox change.

I started with this but it was very bouncy and I couldnt get the listbox changed before the editor would SUBMIT.

        //submit on listbox change
        
        $('#ApForm').on('focus', 'select', function () {
                editor
                    .submit();
         });

To eliminate the bounce, I changed to this.

        //submit on listbox change
        
        $('#ApForm').on('focus', 'select', function () {
                $('#ApForm').on('change', 'select', function () {
                editor
                    .submit();
                 });
         });

The above "de bouncing" trick works only once, it wont work if you need to edit/change a 2nd listbox.

Any ideas for either a different way to handle the "de bounce" or a different event that wouldn't be as "bouncy"?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    I'm not sure exactly what you are trying to do but maybe you just need the change event, like this:

            $('#ApForm').on('change', 'select', function () {
            editor
                .submit();
             });
    

    Kevin

  • dpanscikdpanscik Posts: 202Questions: 47Answers: 0

    on change by itself is also super bouncy. As soon as I click on the listbox, before I make a new selection, the editor submits.

  • dpanscikdpanscik Posts: 202Questions: 47Answers: 0

    As soon as I click on the listbox, before I make a new selection, the editor submits.

    I start with this on DT

    when i click on inline editor I get this and the form submits

    i never get an opportunity to make a change like here

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    Yes, you need to know if it is Editor that is setting the value, or the end user. Editor passes a second parameter to the event handler to indicate this, so use:

    $('#ApForm').on('change', 'select', function (e, d) {
      if (! d) {
        editor.submit();
      }
    });
    

    Allan

  • dpanscikdpanscik Posts: 202Questions: 47Answers: 0

    Magic! That was the solution!

Sign In or Register to comment.