backbone-routing

Backbone.js Router initialization doesn't run immediately

五迷三道 提交于 2019-12-20 02:07:06
问题 My code is as follows: var AppRouter = Backbone.Router.extend({ _data: null, _length: 0, _index: null, _todos: null, _subtodolist: null, _subtodos: null, routes: { "*action": "index", "category/:name": "hashcategory" }, initialize: function(options){ var self = this; if (this._index === null){ $.ajax({ url: 'data/todolist.json', dataType: 'json', data: {}, success: function(data) { self._data = data; self._todos = new TodosCollection(data); self._index = new CategoriesView({collection: self.

BackboneJS - Router issues - how to get clean URL's

廉价感情. 提交于 2019-12-12 07:24:10
问题 ok I have {{#each mainmenu}} <li> <a href="#pages/{{this.url}}"><h2>{{this.name}}</h2></a> </li> {{/each}} and in my router routes: { '': 'index', 'pages/firstpage' : 'firstpage', 'pages/secondpage' : 'secondpage', 'pages/thirdpage' : 'thirdpage' }, initialize: function () { Backbone.history.start({pushState: false}); } and my json file is: { "name":"First page", "id":"1", "url":"firstpage" }, { "name":"Second page", "id":"2", "url":"secondpage" }, { "name":"Third page", "id":"3", "url":

Using Backbone LocalStorage and still making calls to the server

為{幸葍}努か 提交于 2019-12-12 03:55:06
问题 How do I make a call to the server using Backbone localStorage I saw this question, but I am not sure where I apply it? Backbone.js able to do rest and localstorage? Here is my code for the view: define([ 'jquery', 'underscore', 'backbone', 'models/song', //'collections/songs', //'views/song', 'text!templates/search.html' ], function($, _, Backbone, SearchM, SearchT){ //Song, Songs, SongV, var Search = Backbone.View.extend({ model: SearchM, el: $("#Sirius"), events: { 'submit #searchMusic':

How to get this backbone route to work?

℡╲_俬逩灬. 提交于 2019-12-11 06:15:08
问题 CI'm having problems with making one route works. I have list view with items, single item html looks like this: <li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-li-has-count ui-btn-up-c"><div class="ui-btn-inner ui-li"><div class="ui-btn-text"> <a href="#my_clients/1486" class="ui-link-inherit"> <h4 class="ui-li-heading">number/h4> <span

Backbone.history.navigate doesn't save parameters

青春壹個敷衍的年華 提交于 2019-12-11 04:22:57
问题 I have some routes: routes: { "": "main", "!/": "main", "!/page": "page", "!/page/:id": "page" }, Then I have some html link, for example: <a href="site.com/#!/page/3">my link</a> If i press to my link I access to url site.com/#!/page/3 and it's ok for me. But if I have this link: <a href="javascript:void(0);" onclick="Backbone.history.navigate('!/page/3', {trigger:true});">my link</a> I access to url site.com/#!/page/ (without id=3 ). Id is still defined. But after page reloading, I have a

Backbone.History.extend( { loadUrl: …} ) returning false for valid routes

落花浮王杯 提交于 2019-12-11 03:31:22
问题 I'm trying to extend Backbone.History.loadUrl() to catch 404 errors: var History = Backbone.History.extend({ loadUrl: function() { var match = Backbone.History.prototype.loadUrl.apply(this, arguments); if (!match) { console.log('route not found'); } return match; } }); (Backbone.history = new History).start(); This is based on the solution suggested here: https://github.com/jashkenas/backbone/issues/308#issuecomment-9482299. The problem I'm encountering is that when I call (Backbone.history =

How to design a controller in Backbone.js?

你说的曾经没有我的故事 提交于 2019-12-11 02:22:29
问题 I am interested in having a controller to coordinate rendering, event processing, URL router navigation and network access. A bit similar to what a Controller does in Spine: http://spinejs.com/docs/controllers In the realm of Backbone, what I could find so far is an article by Derick Bailey: http://lostechies.com/derickbailey/2011/08/28/dont-execute-a-backbone-js-route-handler-from-your-code/ In Derick's code however, the Controller seems not to be used anymore within the Routes. Also, I was

Backbone routing doesn't work when converted to TypeScript

时光怂恿深爱的人放手 提交于 2019-12-11 01:36:41
问题 I'm trying to convert a basic Backbone.js router declaration to TypeScript. var AppRouter = Backbone.Router.extend({ routes: { "*actions": "defaultRoute" }, defaultRoute: function () { document.write("Default Route Invoked"); } }); var app_router = new AppRouter(); Backbone.history.start(); My converted code is the following which doesn't work: class AppRouter extends Backbone.Router { routes = { "*actions": "defaultRoute" } defaultRoute() { document.write("Default Route Invoked"); } } var

Anchors in links

不问归期 提交于 2019-12-10 09:25:42
问题 Given: Tom — who has a modern browser which is pushState-enabled Fred — who has a browser which is not pushState-enabled a super.app web application powered by Backbone Tom browses to products/1 page where a #special-offer section exists. Does Backbone allow Tom to share a link with Fred including the anchor to the special-offer section: http://super.app/products/1#special-offer Will Fred be redirected to http://super.app/#products/1 (eg: without the #special-offer )? In other words, does

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

浪子不回头ぞ 提交于 2019-12-09 10:43:52
问题 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 been initialised, the subApps needs the router for making router.navigate . Here the schema: main.js -> router -> app -> subApp -> router Then I have a problem of Circular Dependencies and for that reason the router in subApp will be undefined. What is