[SOLVED] Return view to default

Quick explanation: This is a 2 players prematch view. So there is a “Ready” button that will be disabled by default. When game has 2 player the button will be enable(disabled false).

The problem comes when someone leave that view and i try something like:

		
		console.log("button atras pressed")
		
		

		app.request.post('herokuserverlink', { uuid: device.uuid }, onSuccess, onError);

		function onSuccess(data, status, xhr) {
			if (status === 200) {
				console.log(data);
				console.log(device.uuid);
			};
			disableButtonListo();
			view.router.back()
		}
		function onError() {
			console.log("error en post removeplayer")
		}
	});

function disableButtonListo(){
	console.log("joined function diableButtonListo")
	$$('#buttonlisto').prop('disabled', true);
}

I have tried to set the button disabled everytime u left the view by using page:beforeout.

Is there any way to return the view as it was by default everytime i left it or anything that can just help me doing this, i would be very pleased if u can tell me something helpfull.

This is my first post. I am sorry if i am not asking it propperly.
Thanks for your help

From the code i read i think you speek Spanish. If thats the case we can continue in Spanish.

Try with:

reloadPrevious: true

reloadPrevious (boolean) - replace the previous page in history with the new one from route

https://framework7.io/docs/view.html#router-api-methods-properties

1 Like

Thanks for that im gonna try to explain in spanish.

Creo que no me expliqué de forma correcta. Voy a intentar hacerlo algo mejor esta vez.
Imagina que tenemos los path o views /home y /prematch definidas

desde home redirijo a prematch. que es dónde se encuentra el problema. Tengo un botón " Listo" que por defecto está deshabilitado y cuando los 2 jugadores se unen a la partida, ese botón se habilita. si uno se sale, se deshabilita, hasta ahí todo correcto.

El problema está en cuando el usuario quiere retroceder o salirse de la partida. Como se puede ver en el codigo que he posteado, primero vuelve a asignar la propiedad disabled = true al botón y después hace un view.router.back() para volver al home. El problema es, que si después vuelves a entrar en prematch, el botón no estará deshabilitado por defecto, es decir, no ha cambiado realmente la propiedad.

Por eso me gustaría saber, hay alguna manera de dejar la view como se encontraba al principio? o alguna idea de cómo cambiar la propiedad y después volver a la view anterior. de forma que funcione?

Muchas gracias de antemano

te dejo un jsfiddle.

creo q es lo que necesitas, tenes 2 acciones. una que vuelve sin modificar el estado y la otra que lo vuelve al estado original.

jsfiddle

Saludos

1 Like

Muchísimas gracias !

1 Like