Skip to content

Instantly share code, notes, and snippets.

@BriceShatzer
Last active January 4, 2016 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BriceShatzer/8602060 to your computer and use it in GitHub Desktop.
Save BriceShatzer/8602060 to your computer and use it in GitHub Desktop.
WPD - doc tracking
// - orginal code
// worked but triggered pop block and would open in a new window instead of a new tab
$('a.docLink').click(function(event) {
event.preventDefault();
var documentURL = $(this).attr('href');
$.post (submissionURL, theInfo)
.always( function() {
var win=window.open(documentURL,'_blank');
win.focus();
});
});
// Found this: http://stackoverflow.com/a/13158856/1608016
// so I changed the code to this:
$('a.docLink').click( function(event){
event.preventDefault();
var documentURL = $(this).attr('href');
$.ajax({
url: submissionURL,
type: 'POST',
data: theInfo,
async: false
})
.always(function() {
var win=window.open(documentURL,'_blank');
win.focus();
});
});
// works as intended (page opens in a new tab, post is sucessful)
// why does async: false change the behavior of the new window opening?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment