You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
27 lines
690 B
27 lines
690 B
export class UIRenderer { |
|
constructor(path) { |
|
this.templatePath = path; |
|
} |
|
render(template, tag = "#block-content") { |
|
this.get_template((reponse) => { |
|
$('body').html(reponse); |
|
this.get_template((reponse) => { |
|
$(tag).html(reponse); |
|
}, template) |
|
}); |
|
} |
|
get_template(callback, template = "") { |
|
let url = template === "" ? `${this.templatePath}/template.html`: `${this.templatePath}/${template}`; |
|
let data = $.ajax(url,{ |
|
async: false, |
|
method: "GET", |
|
success: callback, |
|
fail: (err) => { |
|
console.log(err); |
|
} |
|
}); |
|
} |
|
add_event(tag, action, callback) { |
|
$("body").on(action, tag, callback); |
|
} |
|
}
|
|
|