Skip to content

Commit

Permalink
Make sure JITMs are only queried once when switching dash tabs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeherve committed Dec 21, 2018
1 parent c0335a2 commit 3fdcfc0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions _inc/jetpack-jitm.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,15 @@ jQuery( document ).ready( function( $ ) {

reFetch();

$( window ).bind( 'hashchange', function() {
var jitm_card = document.querySelector( '.jitm-card' );
if ( jitm_card ) {
jitm_card.remove();
}
reFetch();
$( window ).bind( 'hashchange', function( e ) {
var newURL = e.originalEvent.newURL;

if ( newURL.indexOf( 'jetpack#/' ) >= 0 ) {
var jitm_card = document.querySelector( '.jitm-card' );
if ( jitm_card ) {
jitm_card.remove();
}
reFetch();
}
} );
} );

0 comments on commit 3fdcfc0

Please sign in to comment.