Basic Navigation

Configuration

When you call DZ.init, you have to set the 'ajax' parameter to true.

DZ.init({
    ajax: true
});
            

This will inform the SDK that you don't need Deezer to automaticaly set the URL.
You will then be able to use to DZ.navigation.setPage() and DZ.navigation.onPageChanged()

Methods

DZ.navigation.setPage

This method allows you to interact with the Deezer URL.
For example, calling DZ.navigation.setPage('/inapp/navigation/mypage1')
will set the Deezer URL to:
http://www.deezer.com/app/{app_id}/inapp/navigation/mypage1
See the demo below

DZ.navigation.onPageChanged

This method takes a callback as a parameter.
It is based on the Deezer SDK event handler. The event name is 'page_changed', so you can also use DZ.Event.subscribe.


Each time the Deezer URL is changed from outside of your app, this callback will be invoked, with the new path as a parameter.
For example, if the user navigates from /inapp/navigation/mypage1 to /inapp/navigation/mypage2 in your application and then clicks on his browser's back button, your callback will be invoked, and the parameter value will be '/inapp/navigation/mypage1'.

DZ.navigation.onPageChanged(function(path){
    console.log('the new url is ', path);
});

DZ.Event.subscribe('page_changed', function(path){
    console.log('the new url is ', path);
});
            

Demo

mypage1 mypage2 mypage3

PAGE: home (from url)