backbone-routing

Programmatically adding routes to Backbone.Router?

痴心易碎 提交于 2019-12-08 17:07:26
问题 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': 'showModalError' }, defaultRoute : function(other) { $('#modal404').modal(); } }); In main javascript file application.js i'd like to programmatically add routes. I've tried with route() function and it doesn't work, routes are not added. It works however passing an object

Backbone: Adding a model to Collection and render a View

微笑、不失礼 提交于 2019-12-08 12:00:26
问题 I'm building a simple Backbone app where I mainly have a view with a list of books (book name + cover image) and another view where I want to add new books to the list. When I use a sample data the view with the books renders properly, but when I try to add books to the list it doesn't work and I don't know which is the problem. Here is the JSFiddle http://jsfiddle.net/swayziak/DRCXf/4/ and my code: HTML: <section class="menu"> <ul class="footer"> <li><a href="">List of Books</a></li> <li><a

Backbone - Create Multiple Models in Collection - serverside

浪子不回头ぞ 提交于 2019-12-08 05:00:33
问题 I provide a form for users to upload their own data. I use ajax-form-submit and then parse the data to create numerous models (one per row in uploaded csv). Now, I want to create models into a predefined collection. I can use add which takes an array of models but unfortunately, it does not send PUSH at server side. I know I can iterate and create .create for each model but let's say I have 10k models, it would create 10k calls. Sounds unreasonable. Did I miss anything? The other way is to

What's the difference between Backbone.history.navigate and this.router.navigate

我们两清 提交于 2019-12-08 03:08:12
问题 What is the difference between Backbone.history.navigate and this.router.navigate ? Why would sometimes the former work while later won't? 回答1: If you look at the Backbone source, you'll see that Router.prototype.navigate is simply a proxy to Backbone.history.navigate which you can call anywhere without the need for a router instance. // Simple proxy to `Backbone.history` to save a fragment into the history. navigate: function(fragment, options) { Backbone.history.navigate(fragment, options);

Backbone.js router using pushstate with XAMPP apache server on localhost

纵饮孤独 提交于 2019-12-07 11:43:46
问题 I'm trying to get backbone.js's router to work with my XAMPP apache server on localhost. I need to prevent apache from evaluating the directory paths that are supposed to go to the router and just forward everything to /test_backbone/index.html . I've tried everything that I could find, nothing works. Currently, I have this in httpd.conf file: # html5 pushstate (history) support: <ifModule mod_rewrite.c> Options +FollowSymLinks IndexIgnore */* # Turn on the RewriteEngine RewriteEngine On #

Backbone - Create Multiple Models in Collection - serverside

大憨熊 提交于 2019-12-06 16:40:44
I provide a form for users to upload their own data. I use ajax-form-submit and then parse the data to create numerous models (one per row in uploaded csv). Now, I want to create models into a predefined collection. I can use add which takes an array of models but unfortunately, it does not send PUSH at server side. I know I can iterate and create .create for each model but let's say I have 10k models, it would create 10k calls. Sounds unreasonable. Did I miss anything? The other way is to accept multiple models at server and use .ajax calls and then add manually to the collection for UI

What's the difference between Backbone.history.navigate and this.router.navigate

我与影子孤独终老i 提交于 2019-12-06 13:35:31
What is the difference between Backbone.history.navigate and this.router.navigate ? Why would sometimes the former work while later won't? If you look at the Backbone source , you'll see that Router.prototype.navigate is simply a proxy to Backbone.history.navigate which you can call anywhere without the need for a router instance. // Simple proxy to `Backbone.history` to save a fragment into the history. navigate: function(fragment, options) { Backbone.history.navigate(fragment, options); return this; }, Routing is handled in a global , namespaced in Backbone, History instance . This is meant

Running an Backbone app as an independent JS application - Routes not working

社会主义新天地 提交于 2019-12-06 10:38:56
问题 currently, I run backbone as the front-end of my rails 3.2 application. I need to migrate it into an independent JS application, as part of my putting it as part of Trigger.io. It now exists as its own index.html file, referencing the assets folder. When I open the file, it loads the Backbone modules, but the page remains empty. And when I run fetch() commands, it So, I got a couple of qns: 1) How do I trigger the routes such that it goes to a designated page by default? I know it gets

Backbone.js router using pushstate with XAMPP apache server on localhost

混江龙づ霸主 提交于 2019-12-05 13:31:09
I'm trying to get backbone.js's router to work with my XAMPP apache server on localhost. I need to prevent apache from evaluating the directory paths that are supposed to go to the router and just forward everything to /test_backbone/index.html . I've tried everything that I could find, nothing works. Currently, I have this in httpd.conf file: # html5 pushstate (history) support: <ifModule mod_rewrite.c> Options +FollowSymLinks IndexIgnore */* # Turn on the RewriteEngine RewriteEngine On # Rules RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) /test

Anchors in links

拈花ヽ惹草 提交于 2019-12-05 13:09:32
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 Backbone allow to use anchors? I had a test here http://bl.ocks.org/abernier/raw/3183257/ It appears that