Manuel Meurer
Manuel Meurer

Reputation: 3478

Backbone.js - don't render view/template again

In my app I have a list of products and when you click on a product, a Fancybox opens to show the product details.

Now when the user closes the Fancybox, I change the URL back from '#/product-name' to '#' and the list of products is rendered again, even though it is already there.

My question is:

How do I avoid the product list from being rendered again?

So somewhere either in the list action of my controller or the list view I want to check if the product list is already rendered and don't render it again.

It feels like something that should be possible to accomplish quite easily but I can't get it right.

All ideas appreciated!

EDIT: edited for clarification

Upvotes: 0

Views: 551

Answers (2)

Emil Stenström
Emil Stenström

Reputation: 14106

Have a look at backbone:s saveLocation method. It doesn't trigger a hashchange event.

Upvotes: 1

Denny
Denny

Reputation: 89

You only need to change the hash part of your url.

window.location.hash = ""

Upvotes: 1

Related Questions