Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panel problem when click back button on device #1264

Closed
1 of 3 tasks
atukilham opened this issue Dec 30, 2016 · 8 comments
Closed
1 of 3 tasks

Panel problem when click back button on device #1264

atukilham opened this issue Dec 30, 2016 · 8 comments

Comments

@atukilham
Copy link

atukilham commented Dec 30, 2016

This is a (multiple allowed):

  • bug
  • enhancement
  • feature-discussion (RFC)

I have a problem with panel.
When i open panel, and click back button on device, panel not closed and page was back to previous page.
How to make it just close panel without go to back page.
I was tried with check the body'class in pageBack events, if the body have class .with-panel-left-cover, close the panel and it's work.
But my problem, the page also turn back to previous page.

Help me please..

@valnub
Copy link
Collaborator

valnub commented Jan 21, 2017

Hi, can you post a working example on Codepen? Thanks

@ZanderBrown
Copy link
Contributor

Probably related to #150

@valnub
Copy link
Collaborator

valnub commented Jan 22, 2017

I was tried with check the body'class in pageBack events, if the body have class .with-panel-left-cover, close the panel and it's work.
But my problem, the page also turn back to previous page.

Did you try event.preventDefault() ?

@atukilham
Copy link
Author

atukilham commented Jan 22, 2017

@valnub , thanks for reply.
I think my problem same with #150 like @ZanderBrown said.

I use pushState:true,
the problem just with page back clicked on browser or back button on android device, not the framework back button when panel show. I think modal datepicker have same problem like this.

Where i must use event.preventDefault(), can give me an example?
Thanks

@valnub
Copy link
Collaborator

valnub commented Jan 22, 2017

Oh, I see you mean the back button of the Android device. I thought you might be able to put that code into the click event listener of Framework7's back button.

Hm, to be honest I don't know how to do this. You'll probably have to mess around with popstate event.

@Deep18
Copy link

Deep18 commented Feb 21, 2017

@atukilham
This is how i did it.
First of all add an id to the left panel div like this
<div id="left_panel" class="panel panel-left panel-cover sidebar">
add an eventlisterner on back button and check for the active class with hasClass function on the listerner.

document.addEventListener("backbutton", onBackKeyDown, false); 

function onBackKeyDown() { 
	
	 if ($$('#left_panel').hasClass( "active" )) 
		{ myApp.closePanel(); 
			return false; 
			} 
			
	else { 
		mainView.router.back();
		} 
		
	return true; 
}

@valnub
Copy link
Collaborator

valnub commented Feb 21, 2017

Awesome, thanks for posting your solution!

@valnub valnub closed this as completed Feb 21, 2017
@ZanderBrown ZanderBrown added this to Resolved in Bug Report Triage Jul 10, 2017
@lock
Copy link

lock bot commented Jun 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the outdated label Jun 25, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jun 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Bug Report Triage
  
Resolved
Development

No branches or pull requests

4 participants