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

Already on GitHub? Sign in to your account

loadPage('myurl',{reload:true}); not working as expected #4224

Closed
cjblomqvist opened this Issue Apr 27, 2012 · 5 comments

Comments

Projects
None yet
5 participants

Hi there,

I use loadPage to update a page I always have loaded in the background in my DOM. I first load it as a second page on init, via a server-sida script that includes it in my main page. Then I call loadPage on the same page (with matching data-url and id) but jQuery Mobile seems to append the page to the page-container, instead of replacing the existing one.

DOM @ start:

page-container>
div id="test" data-url="myurl">>/div>

JavaScript run by click event:
$.mobile.loadPage('myurl',{reload:true});

DOM afterwards:

page-container>
div id="test" data-url="test">>/div>
div id="test" data-url="test">>/div>

Unfortunately I don't have time right now to provide a jsFiddle (really sorry about that). If I get a chance I'll make one and make a comment on this issue. A simple workaround is to add a .done on the deferred that loadPage returns that looks for any previous pages with the data-url (or id in this case) and remove them. But I would have guessed that jQueryMobile would have dealt with this for me.

Again, thanks for an amazing framework! Really, really, awesome work!

Contributor

toddparker commented Apr 27, 2012

Thanks! Can you post a test page that illustrates this issue? Template: http://jsbin.com/apisib/edit

Contributor

MauriceG commented Apr 28, 2012

Hi @toddparker
I've built a fiddle and it seems, @cjblomqvist is right.
You can try at: http://jsfiddle.net/MauriceG/TGBJp/
I can reproduce this issue at my local repo.

@MauriceG Thanks a lot for saving me the time! I hope this'll help out you guys to fix it!

Owner

arschmitz commented Oct 24, 2012

@toddparker according to the current docs on loadpage i think this is working as it should the docs say it loads a page into the dom. If reload is true it will ignore any current instance of it and load anyway. This is exactly what is being described and the fiddle is showing. with reload false nothing happens the page already exists. with reload true it loads it into the dom again. The documentation dosent say it will remove it that is part of changepage. Loadpage simply does as described and loads the page. if loadpage removed a current page it could cause big problems if someone loaded the page they are already on with loadpage and reload:true it would remove the currently viewed page and not go anywhere to a new page.

Member

jaspermdegroot commented May 29, 2013

I agree with @arschmitz that this expected behaviour. Closing as not a bug.

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