Mastering Framework7 v2 Router
Vladimir Kharlampidi
43419

Hi Vladimir, any chance to get a soon reply, I am using the v.2 and I love it but because there is no documentation online some things i have to figure it out but this thing I do not know how to make it work…

I need to call a page that display information extracted from my DB… in this case I use ajax request. app.request to make the ajax calls and receive a json object.

this works fine at this point…. and using the router ajax async function … but the problem it is that the json object needs to be in the page I call to display the data there and this page must load lot of external .css and js because it is a gallery slideshow… the ajax works fine and completed and success… but in my case the information is there and in the console but it is not passed to the template of that page… :(

i have tried the option i have … template: also templateUrl, context and componentUrl and the componentURL call the page after ajax but the json object is not passed to that page that contains the <template>…</template> and handlebars

My question: how do I do to pass after ajax success the json object to the page… ?

my code as below this is my router in my index page where something is the page where i have my template… :

var routes = [

// Index page

{

path: ‘/something/’,

async: function (resolve, reject) {

datas = {user:’1223’};

app.request({

url: ‘./assets/scripts/_request.php’,

dataType: ‘json’,

data: datas,

method: “POST”,

crossDomain: true,

statusCode: {

404: function(xhr) {

console.log(‘page not found’);

}

},

complete: function(){

console.log(‘complete’);

},

success: function(response) {

resolve({

page: ‘{{arr}}’,

componentUrl: ‘./pages/something.html’

},

{

context: {

arr : response,

},

});

},

error: function(){

console.log(‘error’);

}

})

}

thanks for your help! I am stuck here and do not find the solution…

I tried also to put the ajax request onPageInit and works as in the router but the data is not passed to the template on that page either it only works if i use static data using the function below

this code below works

return {

data: function (response) {

return {

users: [{‘user:1234’},{‘user:1234’}….],

}

}

but in my case all my data is dynamic from the DB …and reviewing all the samples of the pages in the kitchen-sink folder does not see a sample with ajax request json working with a template page…

thanks for your help