开发者

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

开发者 https://www.devze.com 2023-02-27 06:20 出处:网络
In my app I have a list of products and when you click on a product, a Fancybox opens to show the product details.开发者_JAVA技巧

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

开发者_JAVA技巧

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


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


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

window.location.hash = ""
0

精彩评论

暂无评论...
验证码 换一张
取 消