2014-11-06 69 views
0

我想看看我需要做什麼來使用Backbone但不使用jQuery?使用Backbone.js - 刪除jQuery

我想爲視圖使用Famo.us,所以試圖從Backbone解耦jQuery。我將主要使用Backbone模型和集合 - 雖然可以使用框架來查看並插入「Famo.us」代碼。比特Famo.us有這個集成低的事情要做的名單...

如果我只是想使用骨架的模型和集合,我需要做什麼,以便它沒有jQuery成功運行?

謝謝。

- 我只是試圖與jBone更換jQuery的,但它似乎並不喜歡改變:

require.config({ 
    baseUrl: "js", 
    nodeRequire: require, 
    paths: { 
    "backbone" : "vendor/backbone.min", 
// exoskeleton : "vendor/exoskeleton.min", 
    jbone: "vendor/jbone.min", 
    json2: "vendor/json2", 
    "requirejs": "vendor/requirejs/require", 
    underscore: "vendor/underscore.min" 
    }, 
    shim: { 
    jbone: { 
     exports: "$" 
    }, 
    underscore: { 
     exports: "_" 
    }, 
    backbone: { 
     deps: ["jbone", "underscore", "json2"], 
     exports: "Backbone" 
    } 
    } 
// map: { 
// 'exoskeleton': {'underscore': 'underscore-empty'}, // Remap Exoskeleton to use an empty underscore file. 
// '*': { 
//  'underscore': 'underscore-private', // Everything else in the app that requests _ will use the Backbone.utils version. 
//  'backbone': 'exoskeleton' 
// } 
// } 
}); 

我沒有嘗試外骨骼雖然看不到如何正確使用它的例子 - 這樣我想嘗試並簡單地刪除jQuery並嘗試jBone。

我將爲視圖使用Famo.us,所以只需要使用Backbone作爲MVC的MC部分。

回答

0

主幹僅使用jQuery來操作DOM。如果你不這樣做 - 你不需要jQuery(例如,你只使用模型系統與enother框架或在服務器端工作)。

您也可以使用其他的lib而不是jQuery的(具有相同的API) - 像Eksoskeleton或其他喜歡的 - - 只是重新定義骨幹$

P.S看https://github.com/inkling/backbone.nativehttps://github.com/jashkenas/backbone/wiki/Using-Backbone-without-jQuery

+0

謝謝。我非常感謝所有這些,並閱讀了你提到的鏈接,並考慮了Exoskeleton。 Backbone.Native不提供如何在使用RequireJS時優先加載庫的示例。 – Pandafinity 2014-11-06 12:41:23

+0

如果您想使用ReactJS - 您應該只使用事件/模型/集合 – 2014-11-06 12:44:06

+0

或者您可以使用Backbone.Views並重新定義所有方法以應用ReactOS視圖方法而不是標準DOM工作。你的目標是什麼? – 2014-11-06 12:45:04