$(document).ready(function(){ Ractive.components.student = Ractive.extend({ template:'#student' }); $.getJSON('/data/'+location.pathname.split('/').slice(3).join('/'), function(res){ var ractive = new Ractive.components[location.pathname.split('/')[2]]({ el:'#load', data:res }); }); //Code below here });