Callback for removing multi-selection AC

Home Forums Autocomplete Callback for removing multi-selection AC

Viewing 3 reply threads
  • Author
    Posts
    • #34396
      Jonathan Stamper
      Participant

        I saw there was a callback created for entering a value in the ac, but was curious if there exists a callback or a way to set up an onChange event for when the user removes a selected ac option from a multi-select ac?

        I was going to create a setField originally but noticed that doesn’t work for multi-select ac configurations. Then I noticed the callback and thought I could potentially create what I need by querying the list and re-populating the desired field needed to be set but have it comma separated in the same order as the ac selections. If I just had a way to trigger the repopulate on selection removal tied with the existing selection callback it should be all I need.

      • #34403
        Alexander Bautz
        Keymaster

          There is no callback you can use directly, but removing an item from an autocomplete will trigger any “on change rules” you configure on the field in DFFS. Try setting up a rule that triggers on change and then have this rule call a custom function in your Custom JS where you add your code.

          Alternatively you can add an onclick event like this:

          jQuery("#dffs_YourFieldName").on("mouseup", ".spjs_ac_multi_removeSelected", function(){
              // An item has been removed
          });

          Replace YourFieldName with your actual field name.

          Alexander

        • #34452
          Jonathan Stamper
          Participant

            Ah dang the mouse up is close but still returns the removed item using SetFieldValue. I tried “change” and that didn’t work either. I tried to create a rule but since my ac field is actually a multi-line plain text field I don’t think I can create a rule on that.

            • #34457
              Alexander Bautz
              Keymaster

                Try setting a delay so the code that removes it have time to complete before your custom code triggers:

                jQuery("#dffs_YourFieldName").on("mouseup", ".spjs_ac_multi_removeSelected", function(){
                    setTimeout(function(){
                        // Add your custom code here
                    },500);
                });

                This will delay it 500ms – see if that helps.

                Alexander

            • #34469
              Jonathan Stamper
              Participant

                That was it! Just needed some time before executing. I even included a 3rd option to catch the mouse up event on the spjs_acItem class to continue appending the field next to it as the user starts clicking items all in one go.

                Though it’s a rough/ugly way of setting other fields using multi-select ac it works great!

                • #34477
                  Alexander Bautz
                  Keymaster

                    Thanks for the update – I’m glad you got it up and running.

                    Alexander

              Viewing 3 reply threads
              • You must be logged in to reply to this topic.