Join

Clear the Compare Results When Switching Listing Types

Don't want to mess with code snippets? Request for this to be a feature of MyListing Pro.

Instructions

  1. Create a new JS code snippet.
  2. Copy the contents of code snippet below.
  3. Paste the contents into your code snippet.
  4. Review any notes that I’ve provided.
  5. Save and enable the code snippet.
  6. Test.

Snippet

By default, when you compare Listings on an Explore page and switch to a different Listing Types tab, the compared Listings will follow.

In most cases, this presents an undesirable experience because comparing Listings under a particular Listing Type with Listings from another Listing Type wouldn’t make much sense. It’s comparing apples to oranges.

This code snippet will ensure the compared Listings are cleared out as the user navigates between the various Listing Type tabs.

jQuery( $ => {
 if ( MyListing.Explore ) {
  $('.explore-head .explore-types>div').click(function(){
   MyListing.Explore.compare = []
  })
 }
} );