lazy loading of knockout (used only in attribute dialog)

This commit is contained in:
zadam
2019-08-25 21:59:54 +02:00
parent 24a3f814ed
commit bbe0e9e425
3 changed files with 11 additions and 5 deletions

View File

@@ -4,13 +4,12 @@ import infoService from "../services/info.js";
import treeUtils from "../services/tree_utils.js";
import attributeAutocompleteService from "../services/attribute_autocomplete.js";
import utils from "../services/utils.js";
import libraryLoader from "../services/library_loader.js";
const $dialog = $("#attributes-dialog");
const $saveAttributesButton = $("#save-attributes-button");
const $ownedAttributesBody = $('#owned-attributes-table tbody');
const attributesModel = new AttributesModel();
function AttributesModel() {
const self = this;
@@ -254,9 +253,15 @@ function AttributesModel() {
}
}
let attributesModel;
export async function showDialog() {
utils.closeActiveDialog();
await libraryLoader.requireLibrary(libraryLoader.KNOCKOUT);
attributesModel = new AttributesModel();
// lazily apply bindings on first use
if (!ko.dataFor($dialog[0])) {
ko.applyBindings(attributesModel, $dialog[0]);