laktek / jquery-smart-auto-complete Goto Github PK
View Code? Open in Web Editor NEWAutoComplete plugin with smart defaults and flexibility to customize
Home Page: http://laktek.com/2011/03/03/introducing-jquery-smart-autocomplete/
AutoComplete plugin with smart defaults and flexibility to customize
Home Page: http://laktek.com/2011/03/03/introducing-jquery-smart-autocomplete/
In IE selecting an item by mouse clicking the item was not working.
I changed this code about line 500 FROM:
$(options.resultsContainer).delegate(options.resultElement, 'click.smart_autocomplete', function () {
$(options.context).trigger('itemSelect', [this]);
return false
});
TO
$(options.resultsContainer).delegate(options.resultElement, 'mousedown.smart_autocomplete', function () {
$(options.context).trigger('itemSelect', [this]);
return false
});
after item form suggested items is selected.
binding to itemSelect
returns previous value of input (before setting it to selected item's value)
proposition of fix:
triggerChange:false
to <code$.event.special.itemSelect default function options.triggerChange && $(context).trigger('change');
When enter is pressed, the event fires once, but when the item is selected with the enter key, the event fires twice. Fixing temporarily with _.throttle
Hello,
I've run into a problem with clearResults in IE only. In IE when you submit the form by selecting an item (itemSelect or itemFocus) in IE and then use the browser back button the field is not emptied (still contains the selected text) . This does not happen in FF or other browsers.
I have it fixed like this:
$("#goal_name").smartAutoComplete({
maxResults: 5
delay: 200
forceSelect: false
resultsContainer: $ '#typeahead_search_results'
filter: (term, source) ->
$.ajax({
url: "/goals/find.json",
type: 'get'
})
resultFormatter: (result) ->
"<li>#{result.name}</li>"
}).bind({
blur: (event)->
# we allow the click event to trigger if one of our LIs was clicked on.
# 100ms not enough. will 200 be on all machines?
setTimeout(()->
$("#goal_name").trigger('lostFocus')
, 200)
})
Can you turn on the wiki please?
For the use case of search suggestions it would be nice to have an option to submit a search with the enter key even if none of the completion suggestions were selected. Right now that doesn't seem to be possible because keyCode 13 is always caught and resets the textfield.
Or am I missing something?
TIA,
bkw
Plugin not registering when clicking an item in IE.
Works by pressing enter though.
Tested with IE9
I add my input fields dynamically to the dom, or if there is already data i have multiple fields given. All of them using the same class. If i now bind the plugin on these elements it cause problems. I like the pattern to use 'data' to check if the plugin already exists on an element.
I did it like this...
return this.each(function(i) {
if($(this).data("smart-autocomplete")){
return something....
} else {
init events.....
}
}
Would be cool to have this, especially for event driven plugins :-)
Facing following error : Cannot read the property 'query'
while implementing smart_autocomplete_multiselect
Problems trying binding multiple elements.
$('.produto').smartAutoComplete(
{source: ['Apple', 'Banana', 'Orange', 'Mango']
});
This doesn't works
Sry my english xp
Just an FYI, your documentation says to listen for the "noMatch" event for when no results are available. This should be "noResults".
input keeps on being set to null value after hitting enter
my solution ( worked fine ):
$.event.special.itemSelect
misses check if forceSelect
is enabled or selected_value
is set
so line 291 with $(context).val(selected_value);
should become (options.forceSelect || selected_value) && $(context).val(selected_value);
this fix worked just fine for me
It would be nice if we could boldface the searched text in the results, so for example, if we had typed "cat" into the query field, the results would be:
<ul>
<li><em>Cat</em>ch-22</li>
<li><em>Cat</em>cher in the Rye</li>
<li>The <em>Cat</em> in the Hat</li>
<li>Felix the <em>Cat</em></li>
</ul>
To turn this one it could be one simple option:
emphasis: true
Great job with this by the way.
In a comma separated list, with auto-completion, after I have already selected an option it shows up again in autocomplete.
eg. If I have already chosen United States as one of my Favourite countries then it should not show up again in autocomplete but it does appear again.
Specifically, why set "background: #FFF" (line 114)?
Why not capture the original bg color of the text field and use this when clearing the field?
I don't know if there's any way to detect cursor position with js, but currently the form will submit if someone goes back and forth to change a typo
With select boxes, the labels and the actual values of the options are decoupled so you can show a nice formatted text to the user and still get an id back to plug directly into the database. I couldn't find an easy way of doing that with your plugin?
I think supporting the loosing of the list-focus through a hit of a button would be nice to have.
The jQuery Smart AutoComplete is powerful and very useful!
I was wondering if it is possible to configure the Smart AutoComplete so that if someone presses enter without selecting an item in the suggestion list so that the list remains visible and the field is not emptied? What I would like to do is force the user to choose one of the items in the list of suggestions.
Many people have the habit of typing in the search field and hitting the enter key, instead of pressing a button... and they may be frustrated to see that their search is not performed and the criteria they used has disappeared.
I've tried setting forceSelect
option to false, but it had no impact.
Thank you in advance for your help!
lbriquet
Is there a way I can implement hyperlinks in results?
Right now it seems that if I click a link in a result item, it's functionality is hijacked by Smart Auto Complete which triggers an ItemSelect event.
Hi, just trying out the plugin, but getting errors... also finding the same errors @ the github_instant demo
tested in firefox3.6, firefox 4.
to reproduce:
load the demo @ http://laktek.github.com/jQuery-Smart-Auto-Complete/demo/github_instant
click into search_field
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.