Passing parameters between pages

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:

{
    path: '/message/:msgid/:coldstart?/:push?/',
    url: './pages/message.html',
    on: {
        pageInit: function (e, page) {
            console.log(page.route)
            const { msgid, coldstart, push } = page.route.params;
            messagePageInit(msgid, coldstart, push);
        }
    },
},

That portion should be easy enough to port over.

Next I have to figure out swipe events.

Thanks for all your help!
(I’m sure I’ll have more questions! :slight_smile: )

2 Likes

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.

Hi Vladimir

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’ve gotten null value error1

Could you help me please?

mainView.router.navigate(`/tablero/${String(jornada)}/`, { animate: false });
$$(document).on('page:init', '.page[data-name="tablero"]', function (e){
const page = e.detail;
var jornada = page.route.params.numJornada;
alert("La jornada es "+jornada);
});

Hi Vladimir, thaks for you reply

I wrote your code, but doesen’t works yet.

I have gotten this value has “jornada” ( ${String(jornada)} )error1

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});
}

Look carefully on what i wrote and pay attention to quotes https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

it’s amazing!!! , the secret it’s the " `" character, no way!!!

Thank you so much , you’re the best!!