backbone-routing

Backbone pushState and error 404

浪子不回头ぞ 提交于 2019-12-05 05:15:08
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 - error 404 is returned My route is var AppRouter = Backbone.Router.extend({ routes: { '': 'index', 'show': 'show' }, index: function() { console.log('This is the index page'); }, show: function() { console.log('This is the show page'); } }); new AppRouter; Backbone.history.start({pushState: true}); My .htaccess <ifModule mod_rewrite.c> RewriteEngine

How do I create dynamic URL's with Meteor?

元气小坏坏 提交于 2019-12-05 00:41:12
问题 I'm new to web dev and was blown away by the demo on Meteor's site and would like to use it. I've only used Google App Engine so far and to handle a dynamic URL in the main class I would write something like this: app = webapp2.WSGIApplication([('/[0-9]', HandlePost)], debug=True) This would map any URL's with the numbers 0 through 9 at the end to a handler class that would load an HTML page with the appropriate data for a page using a templating engine such as handlebars. How do I do

Backbone router getting history length for back-button

妖精的绣舞 提交于 2019-12-04 22:13:00
I'm using Backbone inside a PhoneGap application. Like every mobile app I need a back-button functionality. It's basically working perfectly with Backbone, because I can simply use window.history.back() and it just works. The only problem I have is to decide when to display the back button. Using window.history.length does not work, because it's not decremented when using back() (of course, because you can go forward() as well). Is there any way to detect if there's more history or if I'm already at the bottom of the stack? Since the browser doesn't seem to supply this info ( How to check if

Need help understanding the basics of nested views in backbone

天涯浪子 提交于 2019-12-04 11:39:10
问题 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, etc. that don't change in the course of using the application, do I need to render the shell for every route or do I do some kind of checking in the view to see if it already exists? It would seem so to me if someone didn't hit the "home" route

How do I create dynamic URL's with Meteor?

醉酒当歌 提交于 2019-12-03 15:12:09
I'm new to web dev and was blown away by the demo on Meteor's site and would like to use it. I've only used Google App Engine so far and to handle a dynamic URL in the main class I would write something like this: app = webapp2.WSGIApplication([('/[0-9]', HandlePost)], debug=True) This would map any URL's with the numbers 0 through 9 at the end to a handler class that would load an HTML page with the appropriate data for a page using a templating engine such as handlebars. How do I do something similar in Meteor? Use backbone's router, see: http://backbonejs.org/#Router-routes For regexps like

How to define/use several routings using backbone and requirejs

為{幸葍}努か 提交于 2019-12-03 13:13:41
问题 I divided my app in several apps. main.js app.js app1/ |- routing |- controller |- app app2/ |- routing |- controller |- app 1) When I try to use the routers in app1 , they work. 2) When I try to use the routers in app2 , they don't work. 3) If I comment the line 'js/app1/routing', in main.js the routers in app2 work. Why do I get this behaviour? Is there some example of app using multiple routing and requirejs on github? thanks. Here's my code: ** main.js ** define([ 'js/app', 'js/app1

Need help understanding the basics of nested views in backbone

此生再无相见时 提交于 2019-12-03 07:14:00
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, etc. that don't change in the course of using the application, do I need to render the shell for every route or do I do some kind of checking in the view to see if it already exists? It would seem so to me if someone didn't hit the "home" route before moving forward in the app. I haven't found anything helpful about this in my googling, so any

How to define/use several routings using backbone and requirejs

天大地大妈咪最大 提交于 2019-12-03 03:19:48
I divided my app in several apps. main.js app.js app1/ |- routing |- controller |- app app2/ |- routing |- controller |- app 1) When I try to use the routers in app1 , they work. 2) When I try to use the routers in app2 , they don't work. 3) If I comment the line 'js/app1/routing', in main.js the routers in app2 work. Why do I get this behaviour? Is there some example of app using multiple routing and requirejs on github? thanks. Here's my code: ** main.js ** define([ 'js/app', 'js/app1/routing', // the routers in this app work 'js/app2/routing' // the routers in this app do not work but // if

Backbone.js: Router callback not reached

眉间皱痕 提交于 2019-12-02 18:13:19
问题 I'm having trouble getting a simple App example to route. I'm using the backbone-on-rails gem. Here's my App.js.coffee: window.App = Models: {} Collections: {} Views: {} Routers: {} $(document).ready -> MyRouter = Backbone.Router.extend( routes: '' : 'index' index: -> console.log("Inside router") new App.Views.HomeIndex() ) router = new MyRouter Backbone.history.start console.log(router.routes[Backbone.history.fragment]) The router never reaches the index callback and the View is never

Backbone.js: Router callback not reached

不羁的心 提交于 2019-12-02 12:06:13
I'm having trouble getting a simple App example to route. I'm using the backbone-on-rails gem. Here's my App.js.coffee: window.App = Models: {} Collections: {} Views: {} Routers: {} $(document).ready -> MyRouter = Backbone.Router.extend( routes: '' : 'index' index: -> console.log("Inside router") new App.Views.HomeIndex() ) router = new MyRouter Backbone.history.start console.log(router.routes[Backbone.history.fragment]) The router never reaches the index callback and the View is never rendered. Here's the HTML Page that is rendered by Rails: <!DOCTYPE html> <html> <head> <title>App</title>