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

feature request: changePage return value #3409

Closed
pehrlich opened this issue Jan 10, 2012 · 3 comments
Closed

feature request: changePage return value #3409

pehrlich opened this issue Jan 10, 2012 · 3 comments

Comments

@pehrlich
Copy link

example:

changedpage = $.mobile.changePage upload_path

currently, returns undefined. I propose that it should return true or false, depending on whether the page was indeed changed, or no change was made due to the requested page being the active page.

This would be convenient triggering events to reinitialize the page in cases where it is already displayed.

@jblas
Copy link
Contributor

jblas commented Jan 10, 2012

@pehrlich

Calling changePage() can result in an asynchronous request to load an external page, in which case we can't give the caller a definitive answer. We currently fire off pagebeforechange and pagechange events which you can read about here:

http://jquerymobile.com/test/docs/api/events.html

I remember thinking we should return a deferred promise object, but there was a complicating factor that isn't coming to mind at this second. In either case the changePage() might be asynchronous.

@pehrlich
Copy link
Author

Hmm. If you do remember the complications, I'd love to learn more about the issue. I wouldn't mind attempting to write a patch that would return either false/undefined or a deferred object, as a way to get to learn the source a little better.

Just to give an idea of the code I'd wish to simplify, here's the snippet:

if $.mobile.activePage.attr('id') == 'edit_upload_page'
    window.pageshow['edit_upload']()
  else
    $.mobile.changePage upload_path

Note that I've circumvented the normal event path-- both because I don't have an event object to send as an argument, and because I'm experimenting with enforcing simpler ways of handling voluminous page events.

@toddparker
Copy link
Contributor

Thanks, please add a link to this to the feature request wiki page here on github. We'll re-open when we decide to work on this in a milestone.
https://github.com/jquery/jquery-mobile/wiki/Feature-Requests

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

No branches or pull requests

3 participants