Backbone supplies structure to JavaScript-heavy applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interface.
yakczh

有用过Backbone的吗,backbone在不同路由跳转的时候可以从服务器取模板吗?还是说要所有的模板都要取回来?

  •  
  •   yakczh · Dec 27, 2012 · 8164 views
    This topic created in 4903 days ago, the information mentioned may be changed or developed.
    4 replies    1970-01-01 08:00:00 +08:00
    loddit
        1
    loddit  
       Dec 27, 2012
    从服务器取模板必然需要ajax加载,体验不够流畅,而往往前端模板都不是很复杂,好处也往往大于坏处,所以直接带上比较好。
    jackyz
        2
    jackyz  
       Dec 28, 2012
    简短回答:

    1,可以的。
    2,不用,不过这样最简单(代价也不大)。

    异步加载模版请自己放 google 找 backbone.marionette 的例子。
    yakczh
        3
    yakczh  
    OP
       Dec 28, 2012
    App.Controllers.Routes = Backbone.Controller.extend({
    routes: {
    "!/hello" : "hello",//使用#!/hello驱动路由
    },
    hello : function() { ... }
    });
    这样报错

    TypeError: Backbone.Controller is undefined
    [在此错误处中断]

    App.Controllers.Routes = Backbone.Controller.extend({
    lyuehh
        4
    lyuehh  
       Dec 28, 2012
    Backbone 0.5.3以后就没有Controller了,改叫Route了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3775 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 96821589 · 56ms · UTC 04:34 · PVG 12:34 · LAX 21:34 · JFK 00:34
    ♥ Do have faith in what you're doing.