WordPress database error: [INSERT, UPDATE command denied to user '51213-2'@'10.10.20.207' for table 'wp_options']INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_doing_cron', '1715136281.7119469642639160156250', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)
Did you use the WinJS navigation framework ? If not, you should really take a look at it because it’s can be really useful and powerful !<\/p>\n
Today I needed to cancel the navigation from a page based on the current state of the page<\/strong>. It could be useful to zoom out of a semantic zoom instead of navigating back when the user tap the little arrow (windows phone habit \ud83d\ude42 ).<\/p>\n I was wondering how I would be able to code this and it turned out that this is pretty easy.<\/p>\n <\/p>\n Th is done in several steps :<\/strong><\/p>\n Detecting that the user request a navigation is easy as an event subscription. [javascript] In the onBeforeNavigate method, you can set a promise which will tell the navigation system if the navigation must be canceled<\/strong>. [javascript] \/\/let the navigation proceed (this is the default behavior) When the navigation must be proceed, you have to remove your subscription to the event because<\/strong> it would be raised on each navigation. Simple as this code : This is my first post on WinJS : let’s celebrate \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":" Did you use the WinJS navigation framework ? If not, you should really take a look at it because it’s can be really useful and powerful ! Today I needed to cancel the navigation from…<\/p>\n","protected":false},"author":3,"featured_media":1077,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[28],"tags":[],"_links":{"self":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/1066"}],"collection":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/comments?post=1066"}],"version-history":[{"count":11,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/1066\/revisions"}],"predecessor-version":[{"id":1076,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/1066\/revisions\/1076"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/media\/1077"}],"wp:attachment":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/media?parent=1066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/categories?post=1066"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/tags?post=1066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\n
Detect the navigation<\/h2>\n
\nThe subscription is done on the “onBeforeNavigate” event of the Navigation object<\/strong>.
\nI usually do it on the ready method which is called whenever a user navigates to the page.<\/p>\n
\n WinJS.Navigation.addEventListener("beforenavigate", onbeforeNavigate);
\n[\/javascript]<\/p>\nCancel or not the navigation<\/h2>\n
\nThis is done using the provided event param ‘setPromise’ method. Here is an example :<\/p>\n
\nfunction onbeforeNavigate(eventObject) {
\n \/\/cancel the navigation
\n eventObject.detail.setPromise(WinJS.Promise.wrap(true));<\/p>\n
\n eventObject.detail.setPromise(WinJS.Promise.wrap(false));
\n}
\n[\/javascript]<\/p>\nIf not canceled, perform some clean-up code<\/h2>\n
\n[javascript]
\n WinJS.Navigation.removeEventListener("beforenavigate", onbeforeNavigate);
\n[\/javascript]<\/p>\n