I found your way too… figured it out after I posted the other method. I suspect your way will be how I get the parameters and I’ll pass those on to a page init function as in:
Hello,
Thankyou for these posts. Hoping someone can answer another question.
I have the following route :
{
path: ‘/modifyBug/’,
componentUrl: ‘pages/modifyBug.html’,
},
And was trying to activate with :
function modifyBug(context, id, quick) {
app.views.main.router.navigate( “/modifyBug/”, {
params: { “context”: context, “bugId”: id },
} );
}
After reading this post, I have changed the rouet to :
path: ‘/modifyBug/:context?/:bugId?/’,
and the call to
app.views.main.router.navigate( “/modifyBug/XX/YY/”) and it seems as if it works some of the time now.
I think the trailing slash on the optional second parameter was my initial issue. It would cause things to just stop working with no error?
Second question? Is there a way to make it work with the params object instead ? Every time I use that, the parameters are empty in the pageInit function.
I am not sure if this is not possible or if I have to set the route destination or if it is the trailing slash issue? I am not seeing errors, it just crashes.
Question … Are there any change about passing parameter between pages with the new version v5.7.10 ?
I can’t achieve send and recieve parameters
routes: [
{
path: '/tablero/:numJornada/',
url: 'views/tablero.html',
name: 'tablero',
},
],
// ... other parameters
});
var mainView = app7.views.create('.view-main');
To call page…
function getDatosJuego(){
var fecha = $$('#fecha-hora-juego').text();
var torneo = $$('#nombre-torneo').text();
var jornada = $$('#id_torneo').text();
mainView.router.navigate({
name: 'tablero',
params: { numJornada: String(jornada)},
options: {animate:true}
});
}
To get values in new page (tablero.html, page-init)
$$(document).on('page:init', '.page[data-name="tablero"]', function (e){
var jornada = app7.view.main.router.currentRoute.params.numJornada;
alert("La jornada es "+jornada);
});
I have gotten this value has “jornada” ( ${String(jornada)} )
function getDatosJuego(){
var fecha = $$('#fecha-hora-juego').text();
var torneo = $$('#nombre-torneo').text();
var jornada = $$('#id_torneo').text();
mainView.router.navigate('/tablero/${String(jornada)}/',{animate:true});
}