Slide 58
Slide 58 text
Data Component
this.navigateUsingPushState = function (e, data) {
$.ajax({
url: data.href,
dataType: 'json',
type: 'GET',
success: function(resp) {
history.pushState(resp, resp.title, resp.url);
$(document).trigger('dataPageRefresh', [resp]);
}
});
};
$(document).on('uiNavigate', this.navigateUsingPushState);
The data component listens for the “uiNavigate” event, makes an XHR for the specified URL, and onSuccess, writes an entry into
the history via pushState(). We then trigger a “dataPageRefresh” custom event.