Fixing taxonomy autocomplete editor

Fixes #6659
This commit is contained in:
Sebastien Ros 2016-03-31 16:31:53 -07:00
parent fbb3047195
commit 4d7fd2f5ba
2 changed files with 4 additions and 2 deletions

View File

@ -87,10 +87,12 @@
$(".terms-editor").each(function () {
var selectedTerms = $(this).data("selected-terms");
var autocompleteUrl = $(this).data("autocomplete-url");
var $tagit = $("> ul", this).tagit({
tagSource: function (request, response) {
var termsEditor = $(this.element).parents(".terms-editor");
$.getJSON("/api/taxonomies/tags", { taxonomyId: termsEditor.data("taxonomy-id"), leavesOnly: termsEditor.data("leaves-only"), query: request.term }, function (data, status, xhr) {
$.getJSON(autocompleteUrl, { taxonomyId: termsEditor.data("taxonomy-id"), leavesOnly: termsEditor.data("leaves-only"), query: request.term }, function (data, status, xhr) {
response(data);
});
},

View File

@ -33,7 +33,7 @@
<fieldset class="taxonomy-wrapper" data-name-prefix="@Html.FieldNameFor(m => m)" data-id-prefix="@Html.FieldIdFor(m => m)">
<label @if(Model.Settings.Required) { <text>class="required"</text> }>@Model.DisplayName</label>
@if (Model.Settings.Autocomplete) {
<div class="terms-editor text text-medium" data-taxonomy-id="@Model.TaxonomyId" data-leaves-only="@Model.Settings.LeavesOnly" data-selected-terms="@selectedTerms" data-allow-new-terms="@Model.Settings.AllowCustomTerms.ToString().ToLower()" data-singlechoice="@Model.Settings.SingleChoice.ToString().ToLower()">
<div class="terms-editor text text-medium" data-autocomplete-url="@Url.HttpRouteUrl("", new { area = "Orchard.Taxonomies", controller = "Tags" })" data-taxonomy-id="@Model.TaxonomyId" data-leaves-only="@Model.Settings.LeavesOnly" data-selected-terms="@selectedTerms" data-allow-new-terms="@Model.Settings.AllowCustomTerms.ToString().ToLower()" data-singlechoice="@Model.Settings.SingleChoice.ToString().ToLower()">
<ul></ul>
@if (Model.Settings.SingleChoice) {
<div class="hint">@T("Enter a single term. Hit <i>tab</i> or <i>enter</i> to apply the term.") @if (!Model.Settings.AllowCustomTerms) { <text>@T("This taxonomy does not allow you to create new terms.") </text> }</div>