Skip to content

Commit

Permalink
hack version with special event listener for popstate (rather than ov…
Browse files Browse the repository at this point in the history
…erwritten)
  • Loading branch information
bborgesr committed Oct 31, 2016
1 parent 71a6311 commit be6ca86
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 89 deletions.
47 changes: 5 additions & 42 deletions inst/www/shared/shiny.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion inst/www/shared/shiny.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions inst/www/shared/shiny.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/www/shared/shiny.min.js.map

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions srcjs/_start.js
Expand Up @@ -3,20 +3,6 @@

var exports = window.Shiny = window.Shiny || {};

/*
(function(history){
var pushState = history.pushState;
history.pushState = function(state) {
if (typeof history.onpushstate == "function") {
history.onpushstate({state: state});
}
// whatever else you want to do
// maybe call onhashchange e.handler
return pushState.apply(history, arguments);
};
})(window.history);
*/

$(document).on('submit', 'form:not([action])', function(e) {
e.preventDefault();
});
28 changes: 0 additions & 28 deletions srcjs/init_shiny.js
Expand Up @@ -418,22 +418,10 @@ function initShiny() {
// Send initial URL search (query string) and update it if it changes
initialValues['.clientdata_url_search'] = window.location.search;

// on popstate
window.onpopstate = history.onpushstate = function(e) {
inputs.setInput('.clientdata_url_search', window.location.search);
};

/*
$(window).bind("popstate", function() {
inputs.setInput('.clientdata_url_search', window.location.search);
});

$(window).bind("pushstate", function() {
inputs.setInput('.clientdata_url_search', window.location.search);
});
*/


// This is only the initial value of the hash. The hash can change, but
// a reactive version of this isn't sent because w atching for changes can
// require polling on some browsers. The JQuery hashchange plugin can be
Expand All @@ -459,24 +447,8 @@ function initShiny() {
shinyapp.connect(initialValues);
$(document).one("shiny:connected", function() {
initDeferredIframes();

window.history.pushState({}, "", "#");
window.history.back();

(function(history){
var pushState = history.pushState;
history.pushState = function(state) {
if (typeof history.onpushstate == "function") {
history.onpushstate({state: state});
}
// whatever else you want to do
// maybe call onhashchange e.handler
return pushState.apply(history, arguments);
};
})(window.history);
});


} // function initShiny()


Expand Down
4 changes: 4 additions & 0 deletions srcjs/shinyapp.js
Expand Up @@ -680,6 +680,10 @@ var ShinyApp = function() {

addMessageHandler('pushState', function(message) {
window.history.pushState(message.state, message.title, message.url);
// just to trigger a onpopstate event...
window.history.pushState(message.state, message.title, message.url);
window.history.back();

});

addMessageHandler('updateQueryString', function(message) {
Expand Down

0 comments on commit be6ca86

Please sign in to comment.