Jquery keypress event to trigger autocomplete only on specific keycodes?

What you really need is to be able to filter the value of the field before the autocomplete plugin does the searching. Looking at the plugin it doesn't look like that is built in. BUT that doesn't stop us from adding it Open up the plugin code and find the function lastWord(), look at line 261.

Then add this to that function: if ( options. FormatValue ){ value = options. FormatValue(value); } So the lastWord function should look like: function lastWord(value) { if ( options.

FormatValue ){ value = options. FormatValue(value); } if (!options. Multiple ) return value; var words = trimWords(value); return wordswords.

Length - 1; } Then in your jquery code you can do something like this: $(document). Ready(function(){ var array1 = 'one','two','three'; $('#test'). Autocomplete(array1,{ formatValue: function(value){ if (value.

Search('=') == -1) return ''; return value. Substring(value. Search('=')+1); } }); }) This will let you filter and format the value of the field before the search.

Since you only want to do the search if the value has the "=" character in it you search for it and if its not found you return an empty string. If its found you remove it and everything before it and return what the user is typing in after it.

What you really need is to be able to filter the value of the field before the autocomplete plugin does the searching. Looking at the plugin it doesn't look like that is built in. BUT that doesn't stop us from adding it.

Open up the plugin code and find the function lastWord(), look at line 261. Then add this to that function: if ( options. FormatValue ){ value = options.

FormatValue(value); } So the lastWord function should look like: function lastWord(value) { if ( options. FormatValue ){ value = options. FormatValue(value); } if (!options.

Multiple ) return value; var words = trimWords(value); return wordswords. Length - 1; } Then in your jquery code you can do something like this: $(document). Ready(function(){ var array1 = 'one','two','three'; $('#test').

Autocomplete(array1,{ formatValue: function(value){ if (value. Search('=') == -1) return ''; return value. Substring(value.

Search('=')+1); } }); }); This will let you filter and format the value of the field before the search. Since you only want to do the search if the value has the "=" character in it you search for it and if its not found you return an empty string. If its found you remove it and everything before it and return what the user is typing in after it.

Thanks so much for the reply. After fumbling for 2 days I figured there had to be some kind of customization to the plugin itself. My requirements have actually gotten a little more tricky.

A function has parameters, and each parameters are autocompletes to other arrays. So a function called "functionX" would have a form of "function()" that would show up with the "=" or a form of "param". When the user hits the "" key, the autocomplete would then change to search on the array of that parameter.So if the user typed in "abc " it would then be looking at the other one.

– user146816 Jul 30 '09 at 11:57 So each function has 2 forms, 1 form is like functionName() which all would show up if the user hits "=", and the other form which is just an enclosureStart char and enclosureEnd char. So when the user hits the "" key in my example, no results should be coming back, but on the next key the user should see results from the function's parameter autocomplete. Does that make any sense?

I can email a detailed use-case to you if I could make it any clearer... Again, thanks for much for the help! – user146816 Jul 30 '09 at 12:00.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions