I am building a shopping cart using backbone.js . When some one clicks on 'add to cart' I am making an ajax call using jQuery. Backend is rails. In response I get the new json value for the cart. However if I display the cart view then car view comes up , however the url does not change.
To make the url change I after receiving the response from jQuery I need to do something so that router catches the new url and things proceed from there.
How do I navigate to the #cart
url?
There are really only two ways you can go about changing your domain name — you can change your domain and all associated links at once or you can make the change one section of your site at a time. Both ways risk affecting your SEO, so choose the one better for you.
You can update the URL by calling the navigate method on your router, like this:
router.navigate('cart');
Most likely your view doesn't have access to the router you can do this:
Backbone.history.navigate('cart', {trigger:true}); // router handles view change
Backbone.history.navigate('cart'); // only url is updated
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With