How can I differentiate that whether a page comes into view from forward or backward navigation. I want to run some code only if it is forward navigation.
CASE 1 :- Say you are navigating from 1 page to another - Forward. I.e. using navCtrl.push(Page,params).
Here, you can put your code in constructor(){}. Code in your constructor always gets executed when you push/navigate to a page - Forward. (Rather than push, you can also reset the stack to a rootpage. This is valid then also.)
CASE 2 :- Say you are navigating back from a page - Backward. I.e. manually going back by user in the app or using navCtrl.pop().
Here, I think, there is NOT any in-built way to recognise if you have navigated on a back page. Here you need to build your own logic.
For e.g, PageA -> PageB is your navigation. I have used localStorage variable to set to some value, (e.g localStorage.setItem('isPushed',true)) when navigating from PageA -> PageB.
Now, in PageA I have written this code using ionViewWillEnter():
ionViewWillEnter(){
if(JSON.parse(localStorage.getItem('isPushed')){
localStorage.setItem('isPushed',false);
// Your Code to be executed when entering to back page.
}
}
ionViewWillEnter() always gets executed when the particular page is navigated. So, my idea here is just to detect if it is navigated from a next page to a back page. Hope this helps. :)
NOTE : I have not handled all the conditions related to this. That you have to work it out. This is just an idea of logic to use.
Related
I'm working on an application that has a listing of events and each event has its own detailed show page. Everything seems fine, but one complaint I've received is that we're not maintaining the scroll position when going from the detail page back to the index listing.
For an example of the ideal behavior, go to http://discuss.emberjs.com/, scroll down the page a ways, click a link, then click the back button. You're brought to same place you were previously at, somewhere further down the page.
With our app, if you try to do this, you're brought back to the top of the page while the results are reloaded from the API. Then when the results load, your position is lost.
Is there a way to achieve what Discourse does while using query params?
I'm trying to rebuild a basic app in Famo.us (including it's magic of course). The problem I have is while creating the navigation. Every guide I've seen it only updates the content of the same Surface. In famo.us you can create a navigation but I think it would get very difficult to keep track of the history as the HTML5 history API does. Also the "back" button of Phonegap implement this functionality so it's something we should consider. At last, not less the Angular/Famo.us doesn't include a Router. So my question is, How should we be implementing a navigation system using Famo.us?
You are going to need (well... need...) to use hashbangs for this, or at least, that's how I'm doing it. You're basically using window.location.hash to do the navigation and editing this (even in a browser), does not trigger a page reload but just sends an event to notify the app that the hash has changed, and then you can let the app act on it. Changing the hash also adds a history element, so window.history can be used to navigate to the previous (or next) page(s)!
This is also (sort-of) the way www.famo.us does it:
http://www.famo.us/university/lessons/#/famous-101/displaying/4
I have a site in Django-CMS 2.4.1. I often go into the admin panel and change a page there, e.g. dragging a plugin from one placeholder to another, or just change the details of a plugin.
If I press "Publish draft" straight after this, I often get an error:
PublicIsUnmodifiable: The public instance cannot be published. Use draft.
Alternatively, sometimes I am told that I cannot submit the form as the slug is already taken (by the same page).
I have found that if I navigate away, come back, make the changes again, and press "Save and continue editing", and only then "Publish draft", it often works - but not always.
Also, I have found that I often cannot delete plugins from pages.
Has this happened to anyone else? Has my database somehow become corrupted?
Sorry I can't be more specific, but I thought I'd ask in case others have had the same problem. I am still trying to work out the pattern. The new management command cms check doesn't detect anything wrong.
One thought - I am using mptt version 0.5.5, which is higher than that loaded automatically by Django-CMS (which uses 0.5.2).
Looks like an issue was closed related to the question I'm about to ask, so I wonder if I'm going to be skating on thin ice, but here goes. I feel like even though this is kind of localized by nature, it could be a useful example for other developers dealing with the Like button.
I seem to be having issues regarding the Facebook like button. The infuriating part is that I'm pretty confident I have everything setup properly, and even though the linter says "hey, this all looks kosher!" the like button fails to get the correct content and uses cached info from a different page.
Here's the case: referlocal.com. We serve daily deals, and list them right off the homepage. There can be one of many deals listed on that homepage, so obviously Facebook is seeing just one when it goes to take a peek at the root directory. Now, on the homepage, whatever deal your viewing has a FB Like XFBML tag with href and ref attributes set. Every page that displays a deal also has OG tags pointing directly to the offer view page. Deals can also be viewed on user pages. So, on these three paths:
/
/{username}
/offers/{city}/{title-url-alias}
a like button is included as well as OG tags that point to /offers/{city}/{title-url-alias}. For about 3 weeks, the button worked like a champ. But recently, it's been performing strangely. For any deal, regardless of the 3 locations, it always uses the information cached from the previous days "/" deal. Regardless of the OG tags or origination.
Here's the wildly confusing part. The Facebook Linter is supposed to recache the information on the page, right? Well, it sort of does. It picks up on all of the appropriate information set in the OG tags, but when you click the Like button at the bottom of the page, no dice, still uses the deal FB saw on the homepage from the day before.
I know this is probably killing my argument for localization, but check this out:
http://developers.facebook.com/tools/lint/?url=http%3A%2F%2Freferlocal.com%2Foffers%2Fdallas%2Fget-20-of-authentic-italian-american-cuisine-for-only-10-at-leggios-italian-ristorante-dallas
Regardless of the fact that the linter finds all the appropriate information, the like button at the bottom still is liking a deal FB cached from the previous day.
Any ideas?
I had this problem too. The linter caches things in a very weird manner - seems like the best thing to do is either to add a query string and change it every time, or just rename the file every time you're checking.
That's my first question in here, I've been looking through old questions, but nothing matched with my problem. Here it is.
I'm creating some site with one main functionality. We want this site to display content of other sites, but in a specific way. User chooses let's say two pages from five and want to see their content. He clicks button 'Display' and goes to next page where he finds let's say view from web cam, and here comes problem.
I want to cache image that is hidden behind the url from which image was downloaded, so after refresh image won't be downloaded again, but browser will get it from cache.
I've been looking through documentation of Django, but nothing seemed to be useful.
I know that I should:
1) create table which stores cache
2) add to settings.py some CACHE_BACKEND = ...
3) use #cache_page(300) before declaration of function which returns content which should be cached,
but... it doesn't seem to work.
I will be greateful if someone tells how to solve that problem, maybe with some sort of code showing the mechanism.
Cheers,
Chris.
I think that right way to do this will be to store image somewhere on your server and delete it later with cron or something similar.
Django cache framework wasn't created for the purpose you are trying to use it.