Questions tagged [backbone-routing]

Backbone.js is a JavaScript framework that provides structure to RESTful web applications. Backbone also includes URL fragment or History-based routing. This tag is for questions related to Backbone's routing system.

From the fine manual:

Web applications often provide linkable, bookmarkable, shareable URLs for important locations in the app. Until recently, hash fragments (#page) were used to provide these permalinks, but with the arrival of the History API, it's now possible to use standard URLs (/page). Backbone.Router provides methods for routing client-side pages, and connecting them to actions and events. For browsers which don't yet support the History API, the Router handles graceful fallback and transparent translation to the fragment version of the URL.

419 questions
37
votes
5 answers

navigate route with querystring

Will Backbone.Router.navigate set test to true: var test = false; var Router = Backbone.Router.extend({ routes: { 'posts': 'showPosts' }, showPosts: function () { test = true; } }); router = new…
abernier
  • 22,855
  • 18
  • 73
  • 103
32
votes
4 answers

Why is it considered bad practice to call trigger: true in the navigate function of backbone.js?

I have read in several places that calling the Backbone.history.navigate function is considered bad practice. For example Addy Osmani sais in his book "Developing Backbone.js Applications" It is also possible for Router.navigate() to trigger the…
DanEEStar
  • 5,679
  • 6
  • 33
  • 46
11
votes
1 answer

Backbone.js _ensureElement error

I'm getting this error, when I want to initialize the view from router class. Error is: Uncaught TypeError: Object # has no method '_ensureElement' BlogFormView: App.BlogFormView = Backbone.View.extend({ el: ".data-form", initialize:…
11
votes
1 answer

Get previous router/url in backbone application

I have a backbone application and i would require to know the router from which the current route is accessed. Is it possible? For eg :- I reach #/current from #/test1 and also in another instance, from #/test1. So can i know through some way to…
Roy M J
  • 6,711
  • 6
  • 43
  • 76
11
votes
1 answer

How to trigger the Backbone.Router events in Backbone.js?

Router in Backbone.js is responsible for routing client-side pages, and connecting them to actions and events based on urls. But how to trigger the url change? I mean if the only way to do this is to enclose the element associated with page routing…
chaonextdoor
  • 4,529
  • 13
  • 40
  • 57
10
votes
1 answer

Error: a url property or function must be specified

These are my initial days of working on BackBone.js. I am actually stuck with the router part as i am getting an error in the console "Error: a url property or function must be specified". This is my scenario; I have a click function which…
9
votes
1 answer

Programmatically adding routes to Backbone.Router?

Here is my application-router.js file where i'm creating Backbone.Router object with just only few routes: var App = App || {}; App.Router = Backbone.Router.extend({ routes : { '' : 'showDashboard', // Not shown '*other':…
Polmonino
  • 3,422
  • 8
  • 34
  • 52
9
votes
2 answers

Backbone.js - Dynamic routing for a large site

I am planning to use backbone + require for an application which has more than 30 modules. Instead of creating separate route for each module, I am planning to create something like this. Not sure it this is a best practice. Please guide. routes: { …
Me Unagi
  • 377
  • 5
  • 16
8
votes
1 answer

Alternative to the Backbone router without hash fallbacks and better back/forward state support?

I am currently using the Backbone router for my SPA. It sort of works OK, but I am having a number of small issues: The problem is - I want to either have pushState navigation or none, meaning - app state gets executed (when I pass the "initial" URL…
Julik
  • 7,236
  • 2
  • 28
  • 42
8
votes
3 answers

Backbone pushState and error 404

I'm trying to implement the { pushState : true } but it works only for the base route, not with the other that continue to give me error 404. In Chrome, If I access: http://example.app/ - OK the console message is displayed http://example.app/show -…
Massimiliano Marini
  • 509
  • 1
  • 5
  • 16
8
votes
3 answers

Circular Dependencies for a web app using backbone.marionette and requireJs

I am in the following situation. I am using requireJs to loads module and I don't want to use global variables. The main.js is responsible to load the router. Then the router loads the app and the app loads several subApps. After everything has…
Lorraine Bernard
  • 11,982
  • 21
  • 79
  • 132
8
votes
1 answer

How should I bootstrap my web app using Backbone.Marionette and requireJs

Let's say my app works but I love to learn and to find the best way of doing things. I really appreciate this post about Reducing Backbone Routers To Nothing More Than Configuration. And the following bbclonemail which is not using…
Lorraine Bernard
  • 11,982
  • 21
  • 79
  • 132
7
votes
1 answer

Need help understanding the basics of nested views in backbone

I've been doing a bunch of reading about nested views in backbone.js and I understand a good amount of it, but one thing that is still puzzling me is this... If my application has a shell view that contains sub-views like page navigation, a footer,…
Charles
  • 309
  • 1
  • 16
7
votes
1 answer

redirect route to another

I am trying to redirect route to another before route callback is executed. I have following piece of code: console.log("file loaded"); (function (History) { var _navigate = History.prototype.navigate; _.extend(History.prototype, { …
user606521
  • 11,796
  • 18
  • 90
  • 180
7
votes
1 answer

How disable Backbone.js routing on initial page load

I know the best practises says "your content must be available on page load" and i did it so. If user navigates to /questionnaire/info/id/2, PHP serves the full html. But problem raises after this point, backbone.js matches the same route and…
cnkt
  • 2,863
  • 5
  • 28
  • 42
1
2 3
27 28