Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

prefetching duplicate page in DOM while user click the data-prefetch link quickly after ui showed #8192

Open
caljohnston opened this issue Jul 15, 2015 · 8 comments

Comments

@caljohnston
Copy link

my page1 got some big stuffs, say, a lot of high definition pictures to load.And i have a link
Category in page1. If user click the link very quickly after page1 showed, the Jquery mobile will fetch two category page into DOM!
my Jquery mobile version : 1.4.5

@Ruffio
Copy link

Ruffio commented Jul 15, 2015 via email

@jaspermdegroot
Copy link
Contributor

@caljohnston

Thanks for reporting the issue. If I understand you correctly you have a very heavy page with a link on it to another page which should be prefetched. If you click that link while the heavy page is still being loaded and the other page hasn't been prefetched yet, that other page will be loaded in the DOM twice. Correct?

Like @Ruffio says, can you please provide a test page?

Thanks!

@caljohnston
Copy link
Author

caljohnston commented Jul 16, 2015

Yes! That’s correct. I try to make a test page with the issue shortly. I guess the pagecontainer did not prevent duplicate load of the same page internally.

@caljohnston
Copy link
Author

caljohnston commented Jul 16, 2015

I tried with a light page with only several icons and links. The issue could be reproduced in such a situation too.

@arschmitz
Copy link
Contributor

The issue here is that your basically creating a race condition. prefetch is specifically designed to run asynchronously in the background. To fix this we will need to track pages being prefetched and save the deferred so that we can hook to that if a page is in the process of being prefetched.

@caljohnston
Copy link
Author

caljohnston commented Jul 16, 2015

Yes, that’s the point! So, currently do you have any advice to prevent such a situation? I cannot have my users not click the link if the page is available.

@arschmitz
Copy link
Contributor

i would try making your links point to the internal url not the external one and on failure wait 1 second and try again thats probably the best you can do for now.

@caljohnston
Copy link
Author

caljohnston commented Jul 16, 2015

Yes. You are right. But I wonder if I can listen to an event of the prefetching completion? If I can get the completion event then I can safely enable the link.

But I cannot find any document on the prefetching event. Do you know anything about that?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.