Skip to main content
Source Link
ssdar
  • 465
  • 3
  • 12

Attach a Click event to SPServices.SPAutocomplete

I am using SPAutocomplete for a type ahead input text box as shown below. This works great.

      $().SPServices.SPAutocomplete({
        sourceList: "mySourceList",
        sourceColumn: "mySourceColumn",
        columnName: "DestinationColumn",
        ignoreCase: true,
        numChars: 3,
        slideDownSpeed: 'fast'
    });

I want to write an onChange event on the input text box. Which works only when I type in the input text box and does not work with the autocomplete. I also tried KeyUp, KeyDown, KeyPress - with e=13 which did not work either.

    $('input[title="DestinationColumn"]').on('change', function () {
       // Logic here            
    });

Finally I am trying to attach the click event to the ul list items that dynamically generate during type ahead. Logic here. This is not working either.

   $('ul[id^="SPAutocomplete_DestinationColumn"] li').on('click', function () {
       // Logic here
    });

How can I write an onchange event with auto populate select on an input textbox? Any clues will be greatly appreciated. Thank you.