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

pageload event does not have newly inserted page as a target #3923

Closed
ucavus opened this issue Mar 27, 2012 · 8 comments
Closed

pageload event does not have newly inserted page as a target #3923

ucavus opened this issue Mar 27, 2012 · 8 comments

Comments

@ucavus
Copy link

ucavus commented Mar 27, 2012

I use $(document).bind('pageload', ..., because that event doesn't seem to fire on newly loaded pages' DOM nodes. For event handlers, this is set to the <body>. I don't really understand why since <body> is easily selectable (and there's always good ol' document.body) so it's not very useful, but only jQm knows for sure which is the newly inserted page node, especially when caching pages. That handler call doesn't have the page node as event.target, event.relatedTarget nor as a property of the data argument. It would be really useful to have all the goodness in data associated with the relevant node.

Maybe I'm doing it wrong?

@toddparker
Copy link
Contributor

@ucavus - I'm not sure I follow this issue report, seems more like a question. If this is an issue, please include a test page using the latest (template: http://jsbin.com/uqenom/edit), steps to reproduce, platforms, etc.

@ucavus
Copy link
Author

ucavus commented May 24, 2012

According to the docs: "pageload Triggered after the page is successfully loaded and inserted into the DOM"

see http://jsbin.com/uqenom/6 with your console open.

I think it would have made more sense to have the event fire on the new page's DOM node, since accessing the document and body is trivial but knowing which node was the one that just got inserted is not. It's like jQm says "I just inserted a new node into the DOM, but I'm not telling you which one!"

@toddparker
Copy link
Contributor

@johnbender oe @gseguin - Mind taking a look at this suggestion?

@ucavus
Copy link
Author

ucavus commented Jul 3, 2012

looks like it's (now?) in the data object that's passed to pageload event handlers in 1.1.0 as page, but is not documented on http://jquerymobile.com/demos/1.1.0/docs/api/events.html

@jaspermdegroot
Copy link
Contributor

This is indeed part of the data object (data.url): http://jsbin.com/uqenom/30
Documented here: http://jquerymobile.com/test/docs/api/events.html

Closing as fixed.

@ucavus
Copy link
Author

ucavus commented Dec 19, 2012

This was about the DOM node, not the URL. data.page is still undocumented.

@jaspermdegroot
Copy link
Contributor

@ucavus

Sorry, you are right. data.page: http://jsbin.com/uqenom/32

@agcolom

When we add the info on this page http://jquerymobile.com/test/docs/api/events.html to the new API docs we have to add the page property at "Page Load Events". Let's check the source code to see if there is anything else missing.

@jaspermdegroot
Copy link
Contributor

Opened a ticket for this at the API documentation repo: jquery/api.jquerymobile.com#96

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

No branches or pull requests

3 participants