SPServices.SPAutocomplete for Text filters

May 6, 2010 at 12:00 AM

I would like to use the SPServices.SPAutocomplete functionality on a SharePoint text filter box. This means there's no ColumnName associated with the control. I tred to use the control's genrated ID or Name but to no avail. Any suggestions on how this might work?

Coordinator
May 6, 2010 at 2:57 AM

The rendering of the control may prevent this from working.  Take a look at the DOM on a page where there's a form with a Single line of text column, and you'll see what SPAutocomplete will be looking for. Basically, the Single line of text control can be selected like this:

  var columnObj = $("input[Title='" + opt.columnName + "']");

M.

Jul 21, 2011 at 8:51 AM
Edited Jul 21, 2011 at 9:29 AM

I can confirm that this is *not* working for me either.  It's very strange -

 

i've got 3 input boxes on the page, all with unique titles assigned.  The title attributes are called out precisely in the ColumnName options,

 

Anyway, when the page finishes loading, and the SPAutoComplete functions have run - all three text boxes do respond when text is entered... but the suggestions dropdown div always appears directly underneath the text field which appears first on the page, or rather, the first of the three I'm affecting which appears on the page.  I even tried to initialize them in different orders to see if it had anything to do with the loading of the function, but ... no.  It's as if there's a variable which is not getting re-initialized when the second/third functions are running?  As far as I can tell otherwise, the page is totally fine, all three input boxes have unique names and titles... I'm stumped!  

 

update: i removed all but one of the SPAutocomplete calls, and now the dropdown appears in the appropriate spot, but I'm unable to get the value to populate into the text box.  This is a totally custom form, with almost no SharePoint controls at all, so i'm wondering if that's a contributor - 

Coordinator
Jul 21, 2011 at 12:22 PM

If it's a custom form, then it's really hard to say if it even *ought* to work. You should look at the code for SPAutocomplete and see what it look for in the selectors. The function will only work as written only if the same "hooks" are available.

Not only will the input element need to have the same structure and attributes as the SharePoint default, but the enclosing markup in the DOM will need to match.

M.

Jul 25, 2011 at 5:04 PM

Marc -

I'll definitely take a look when I get the chance...  this is clearly related to something in my custom form; I've got the 'title' attribute set properly, just need the input field to accept a selected 'suggestion.'  I'll dig in when I get a chance...

thanks a lot!