Opti unbind

skamkraft_proto
ambigipathyv ago%!(EXTRA string=1 year)
parent 89cf65364b
commit 530a87b5b0
  1. 8
      js/skama_code/ui/templeting_engine.js

@ -10,7 +10,7 @@ export class TemplateEngine {
$('body').html(reponse); $('body').html(reponse);
this.get_template((reponse) => { this.get_template((reponse) => {
$("#block-content").html(reponse); $("#block-content").html(reponse);
if (this.after_render_callback) this.after_render_callback(this); if (this.after_render_callback) this.#flush_events().after_render_callback(this);
}, template) }, template)
}); });
} }
@ -24,7 +24,6 @@ export class TemplateEngine {
get_template(callback, template = "") { get_template(callback, template = "") {
let url = template === "" ? `${this.templatePath}/template.html`: `${this.templatePath}/${template}`; let url = template === "" ? `${this.templatePath}/template.html`: `${this.templatePath}/${template}`;
$.ajax(url,{ $.ajax(url,{
async: false,
method: "GET", method: "GET",
success: callback, success: callback,
error: (err) => { error: (err) => {
@ -37,6 +36,11 @@ export class TemplateEngine {
$("body").on(action, tag, callback); $("body").on(action, tag, callback);
} }
#flush_events() {
$("body").unbind();
return this;
}
after_render(callback) { after_render(callback) {
this.after_render_callback = callback; this.after_render_callback = callback;
} }

Loading…
Cancel
Save