0

I use a router script called "Routie" that works so:

routie = ({
   "": function(){
      //code after routing
   },
   "home": function(){
      //code after routing
   },
   "about": function(){
      //code after routing
   }
});

After, I have a json file,

{
    "links" : [
        {"page" : "Home", "url" : "home", "file" : "template_1.html"},
        {"page" : "About", "url" : "about", "file" : "template_2.html"},
        {"page" : "Contact", "url" : "contact", "file" : "template_3.html"},
        {"page" : "Categories", "url" : "categories", "file" : "template_4.html"}
    ]
}

that extract through this code

readTextFile("menu.json", function(text){
  var data = JSON.parse(text);
}

I will pass my routes according to my json file, making a dinamycally object with the info of the route:

readTextFile("menu.json", function(text){
   var data = JSON.parse(text);
   for(item in data["links"]){
   var key = data["links"][item]["url"];
   var file = data["links"][item]["file"];
   array_rooter[key] = function(){ 
      loader(file,'content'); 
   };
   routie(array_router);
}

But it doesn't work :/

Anyone know what are I doing wrong?

0 Answers0