implemented mirror relations

This commit is contained in:
azivner
2018-11-12 23:34:22 +01:00
parent e7cea59ba7
commit 21d3b0c9d8
13 changed files with 164 additions and 31 deletions

View File

@@ -54,24 +54,34 @@ function initNoteAutocomplete($el) {
$el.prop("data-selected-path", suggestion.path);
});
$el.getSelectedPath = () => $el.prop("data-selected-path");
$el.on('autocomplete:closed', () => {
$el.prop("data-selected-path", "");
});
}
return $el;
}
$.fn.getSelectedPath = function() {
if (!$(this).val().trim()) {
return "";
}
else {
return $(this).prop("data-selected-path");
}
};
ko.bindingHandlers.noteAutocomplete = {
init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
initNoteAutocomplete($(element));
$(element).on('autocomplete:selected', function(event, suggestion, dataset) {
bindingContext.$data.selectedPath = suggestion.path;
bindingContext.$data.selectedPath = $(element).val().trim() ? suggestion.path : '';
});
}
};
export default {
initNoteAutocomplete,
autocompleteSource,
showRecentNotes
}