mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-06 04:21:51 +00:00
修复模板重复加载的问题
需要在 avalon.ready()之后再进行其他动作,需要先初始化模板路径。
This commit is contained in:
parent
6e8baca8c9
commit
fff7fae323
@ -1,42 +1,47 @@
|
||||
define("admin", ["jquery", "avalon"], function($, avalon){
|
||||
function li_active(selector){
|
||||
$(selector).attr("class", "list-group-item active");
|
||||
}
|
||||
define("admin", ["jquery", "avalon"], function ($, avalon) {
|
||||
|
||||
function li_inactive(selector){
|
||||
$(".list-group-item").attr("class", "list-group-item");
|
||||
}
|
||||
avalon.ready(function () {
|
||||
|
||||
function show_template(url){
|
||||
$("#loading-gif").show();
|
||||
vm.template_url = url;
|
||||
}
|
||||
|
||||
var vm = avalon.define({
|
||||
$id: "admin",
|
||||
template_url: "template/index/index.html",
|
||||
hide_loading: function(){
|
||||
$("#loading-gif").hide();
|
||||
function li_active(selector) {
|
||||
$(selector).attr("class", "list-group-item active");
|
||||
}
|
||||
});
|
||||
|
||||
var hash = window.location.hash.substring(1);
|
||||
function li_inactive(selector) {
|
||||
$(".list-group-item").attr("class", "list-group-item");
|
||||
}
|
||||
|
||||
if(hash){
|
||||
li_active("#li-" + hash.replace("/", "-"));
|
||||
show_template("template/" + hash + ".html");
|
||||
}else {
|
||||
li_active("#li-index-index");
|
||||
}
|
||||
function show_template(url) {
|
||||
$("#loading-gif").show();
|
||||
vm.template_url = url;
|
||||
}
|
||||
|
||||
window.onhashchange = function() {
|
||||
var hash = window.location.hash.substring(1);
|
||||
if(hash){
|
||||
li_inactive(".list-group-item");
|
||||
li_active("#li-" + hash.replace("/", "-"));
|
||||
show_template("template/" + hash + ".html");
|
||||
|
||||
if (!hash) {
|
||||
hash = "index/index";
|
||||
}
|
||||
};
|
||||
|
||||
var vm = avalon.define({
|
||||
$id: "admin",
|
||||
template_url: "template/" + hash + ".html",
|
||||
hide_loading: function () {
|
||||
$("#loading-gif").hide();
|
||||
}
|
||||
});
|
||||
|
||||
avalon.scan();
|
||||
|
||||
li_active("#li-" + hash.replace("/", "-"));
|
||||
|
||||
window.onhashchange = function () {
|
||||
var hash = window.location.hash.substring(1);
|
||||
if (hash) {
|
||||
li_inactive(".list-group-item");
|
||||
li_active("#li-" + hash.replace("/", "-"));
|
||||
show_template("template/" + hash + ".html");
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user