mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-20 00:20:03 +00:00
Fix #1751
This commit is contained in:
54
public/js/ff/transactions/show.js
vendored
54
public/js/ff/transactions/show.js
vendored
@@ -25,41 +25,37 @@ $(function () {
|
||||
var transactions = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
identify: function (obj) {
|
||||
return obj.id;
|
||||
},
|
||||
prefetch: {
|
||||
url: autoCompleteUri,
|
||||
filter: function (list) {
|
||||
return $.map(list, function (name) {
|
||||
return {name: name.name};
|
||||
});
|
||||
}
|
||||
url: autoCompleteUri
|
||||
// filter: function (list) {
|
||||
// return $.map(list, function (name) {
|
||||
// return {name: name.name};
|
||||
// });
|
||||
// }
|
||||
},
|
||||
remote: {
|
||||
url: autoCompleteUri + '?search=%QUERY',
|
||||
wildcard: '%QUERY',
|
||||
filter: function (list) {
|
||||
return $.map(list, function (name) {
|
||||
return {name: name.name};
|
||||
});
|
||||
}
|
||||
wildcard: '%QUERY'
|
||||
// filter: function (list) {
|
||||
// return $.map(list, function (name) {
|
||||
// return {name: name.name};
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
transactions.initialize();
|
||||
var input=$("#link_other");
|
||||
var input = $("#link_other");
|
||||
input.typeahead({hint: true, highlight: true,}, {source: transactions, displayKey: 'name', autoSelect: false});
|
||||
|
||||
input.change(function () {
|
||||
var current = input.typeahead("getActive");
|
||||
if (current) {
|
||||
// Some item from your model is active!
|
||||
if (current.name.toLowerCase() ===
|
||||
input.val().toLowerCase()) {
|
||||
// This means the exact match is found. Use toLowerCase() if you want case insensitive match.
|
||||
$('input[name="link_journal_id"]').val(current.id);
|
||||
} else {
|
||||
$('input[name="link_journal_id"]').val(0);
|
||||
}
|
||||
} else {
|
||||
$('input[name="link_journal_id"]').val(0);
|
||||
}
|
||||
});
|
||||
input.bind('typeahead:select', function (ev, suggestion) {
|
||||
console.log('Selection: ' + suggestion.name);
|
||||
if (suggestion.name.toLowerCase() === input.val().toLowerCase()) {
|
||||
// This means the exact match is found. Use toLowerCase() if you want case insensitive match.
|
||||
$('input[name="link_journal_id"]').val(suggestion.id);
|
||||
} else {
|
||||
$('input[name="link_journal_id"]').val(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user