-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support to change or hide label when no matches found #8
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,10 @@ | |
var _e = e; | ||
this.init(_e); | ||
}; | ||
jQuery.railsAutocomplete.options = { | ||
showNoMatches: true, | ||
noMatchesLabel: 'no existing match' | ||
} | ||
|
||
jQuery.railsAutocomplete.fn = jQuery.railsAutocomplete.prototype = { | ||
railsAutocomplete: '0.0.1' | ||
|
@@ -67,9 +71,17 @@ | |
}); | ||
} | ||
jQuery.getJSON( jQuery(e).attr('data-autocomplete'), params, function() { | ||
if(arguments[0].length === 0) { | ||
var options = {}; | ||
jQuery.extend(options, jQuery.railsAutocomplete.options); | ||
jQuery.each(options, function(key, value) { | ||
if(options.hasOwnProperty(key)) { | ||
var attrVal = jQuery(e).attr('data-' + key); | ||
options[key] = attrVal ? attrVal : value; | ||
} | ||
}); | ||
if(arguments[0].length == 0 && options.showNoMatches) { | ||
arguments[0] = []; | ||
arguments[0][0] = { id: "", label: "no existing match" }; | ||
arguments[0][0] = { id: "", label: options.noMatchesLabel }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mixed double and single quotes. |
||
} | ||
jQuery(arguments[0]).each(function(i, el) { | ||
var obj = {}; | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module RailsJQueryAutocomplete | ||
VERSION = '1.0.0' | ||
VERSION = '1.1.0' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.