{"id":108,"date":"2023-08-25T17:34:54","date_gmt":"2023-08-25T17:34:54","guid":{"rendered":"\/\/api.jquerymobile.com\/1.4\/?p=108"},"modified":"2023-08-25T17:34:54","modified_gmt":"2023-08-25T17:34:54","slug":"pagebeforechange","status":"publish","type":"post","link":"https:\/\/api.jquerymobile.com\/1.4\/pagebeforechange\/","title":{"rendered":"pagebeforechange"},"content":{"rendered":"<article id=\"pagebeforechange1\" class=\"entry event\"><h2 class=\"section-title\">\n<span>pagebeforechange event<\/span><span class=\"version-details\">version added: 1.0, deprecated: 1.4.3<\/span>\n<\/h2>\n<div class=\"entry-wrapper\">\n<p class=\"desc\"><strong>Description: <\/strong>Triggered twice during the page change cyle: First prior to any page loading or transition and next after page loading completes successfully, but before the browser history has been modified by the navigation process.<\/p>\n<ul class=\"signatures\"><li class=\"signature\"><h4 class=\"name\">jQuery( &quot;.selector&quot; ).on( &quot;pagebeforechange&quot;, function( event ) { ... } )<\/h4><\/li><\/ul>\n<div class=\"longdesc\" id=\"entry-longdesc\">\n\t\t<p>When received with <code>data.toPage<\/code> set to a string, the event indicates that navigation is about to commence. The value stored in <code>data.toPage<\/code> is the URL of the page that will be loaded.<\/p>\n\t\t<p>When received with <code>data.toPage<\/code> set to a jQuery object, the event indicates that the destination page has been loaded and navigation will continue.<\/p>\n\t\t<p>If the page change cycle was initiated programmatically, and, instead of a URL a jQuery object containing a page was given, then the event will be triggered both times with <code>data.toPage<\/code> set to the jQuery object containing the destination page.<\/p>\n\n\t\t<p>The pagebeforechange event is triggered either by explicit navigation on the part of the user (e.g. by clicking on a link or by running code that results in a call to the pagecontainer <code>change()<\/code> method), or by implicit navigation caused by the user clicking the browser&apos;s &quot;Back&quot; or &quot;Forward&quot; buttons.<\/p>\n\t\t<p>Explicit navigation results in both pagebeforechange events being triggered before a new entry is added to the browser&apos;s navigation history.<\/p>\n\t\t<p>Implicit navigation results in both pagebeforechange events being triggered after the browser&apos;s navigation history has been updated.<\/p>\n\t\t<p>In addition to the <code>event<\/code> parameter, handlers of this event will receive a second parameter, <code>data<\/code>. The second parameter is an object containing the following properties:<\/p>\n\t\t\t<ul>\n\t\t\t\t<li>\n<code>toPage<\/code> (object or string)\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t<li>This property represents the page the caller wishes to make active. It can be either a jQuery collection object containing the page DOM element, or an absolute\/relative url to an internal or external page. The value exactly matches the 1st arg to the changePage() call that triggered the event.<\/li>\n\t\t\t\t\t<\/ul>\n\t\t\t\t<\/li>\n\t\t\t\t<li>\n<code>options<\/code> (object)\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t<li>This object contains the configuration options to be used for the current <code>changePage()<\/code> call.<\/li>\n\t\t\t\t\t<\/ul>\n\t\t\t\t<\/li>\n\t\t\t<\/ul>\n\t\t\t<p>It should be noted that callbacks can modify both the <code>toPage<\/code> and <code>options<\/code> properties to alter the behavior of the current <code>changePage()<\/code> call. So for example, the <code>toPage<\/code> can be mapped to a different url from within a callback to do a sort of redirect.<\/p>\n\t\t\t<div class=\"warning\">\n\t<strong>Note:<\/strong> The triggering of this event is deprecated as of jQuery Mobile 1.4.3. It will no longer be triggered in 1.6.0.\n\t<p>The replacement for <code>pagebeforechange<\/code> is the <code><a href=\"\/1.4\/pagecontainer\/\">pagecontainer<\/a><\/code> widget&apos;s <code>pagecontainerbeforechange<\/code> event. In jQuery Mobile &gt;= 1.4.3, the two events are identical except for their name and the fact that <code>pagecontainerbeforechange<\/code> is triggered on the pagecontainer, whereas <code>pagebeforechange<\/code> is triggered on the page.<\/p>\n<\/div>\n\t<\/div>\n<\/div><\/article>","protected":false},"excerpt":{"rendered":"<p>Triggered twice during the page change cyle: First prior to any page loading or transition and next after page loading completes successfully, but before the browser history has been modified by the navigation process.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-108","post","type-post","status-publish","format-standard","hentry","category-events"],"_links":{"self":[{"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":1,"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":109,"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/posts\/108\/revisions\/109"}],"wp:attachment":[{"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}