0

In my view I render collection and I have sort buttons. When sort button is clicked then collection is fetched with some custom query param (like &sort=id+desc). It works but I would like to also change url querystring to this query param (&sort=id+desc). The problem is that it works but it re-renders whole view as router just redirects to different action (actually the same action but with different query params).

How I can just change url query param without reloading view and also add it to history?

I am using pushState in my app

user606521
  • 14,486
  • 30
  • 113
  • 204

1 Answers1

0

You should use backbone router for this.

When application stars you need to run:

Backbone.history.start({pushState: true});

To change the URL just use you router:

router.navigate("something?key=value");

If you don't have a router you just create one:

var router = new Backbone.Router();
ekeren
  • 3,408
  • 3
  • 35
  • 55