Skip to content

Commit

Permalink
Merge remote-tracking branch 'onesupercoder/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
David Padilla committed Oct 27, 2012
2 parents 05c5068 + 2fb078a commit 8ff3c48
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
21 changes: 19 additions & 2 deletions lib/assets/javascripts/autocomplete-rails-uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
jQuery.getJSON( jQuery(e).attr('data-autocomplete'), {
term: extractLast( request.term )
}, function() {
if(arguments[0].length == 0) {
arguments[0] = []
arguments[0][0] = { id: "", label: "no existing match" }
}
jQuery(arguments[0]).each(function(i, el) {
var obj = {};
obj[el.id] = el;
Expand All @@ -58,6 +62,20 @@
response.apply(null, arguments);
});
},
change: function( event, ui ) {
if(jQuery(jQuery(this).attr('data-id-element')).val() == "") {
return;
}
jQuery(jQuery(this).attr('data-id-element')).val(ui.item ? ui.item.id : "");
var update_elements = jQuery.parseJSON(jQuery(this).attr("data-update-elements"));
var data = ui.item ? jQuery(this).data(ui.item.id.toString()) : {};
if(update_elements && jQuery(update_elements['id']).val() == "") {
return;
}
for (var key in update_elements) {
jQuery(update_elements[key]).val(ui.item ? data[key] : "");
}
},
search: function() {
// custom minLength
var term = extractLast( this.value );
Expand Down Expand Up @@ -99,8 +117,7 @@
jQuery(this).unbind('keyup.clearId');
}
});
jQuery(this).trigger('railsAutocomplete.select', ui);

jQuery(e).trigger('railsAutocomplete.select', ui);
return false;
}
});
Expand Down
3 changes: 2 additions & 1 deletion lib/assets/javascripts/autocomplete-rails.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8ff3c48

Please sign in to comment.