2013-09-26 66 views
0

我正嘗試在我的Marionette應用程序中切換Zepto,並試圖使用此zepto插件(https://github.com/sudhirj/simply-deferred)支持jquery的緩存。我也使用require.js,至今頭被埋使其工作,我仍然得到這個錯誤:Deferred,Marionette和Zepto

Uncaught TypeError: Object function (selector, context){ 
    return zepto.init(selector, context) 
    } has no method 'Deferred' 

,這就是我需要的js文件的樣子:

require.config({ 
    paths: { 
    'backbone': 'lib/backbone', 
    'text': 'lib/text', 
    'underscore': 'lib/underscore', 
    'bootstrap' : 'lib/bootstrap', 
    'marionette' : 'lib/backbone.marionette', 
    'localStorage' : 'lib/backbone.localStorage', 
    'less' : 'lib/less', 
    'Email' : 'models/email', 
    "Emails" : 'collections/emails', 
    "FormView" : 'views/FormView', 
    "EmailsView" : 'views/EmailsView', 
    "EmailView" : 'views/EmailView', 
    "NoEmailView" : 'views/NoEmailView', 
    "FormView" : 'views/FormView', 
    "MyApp" : 'app', 
    "parseEmail" : "parsing/parseEmail", 
    "LabelView" : "views/LabelView", 
    'socketio': '../socket.io/socket.io', 
    "zepto" : 'lib/zepto', 
    "deferred" : 'lib/deferred' 
    }, 
    shim: { 
    'zepto':{ 
     deps: ["deferred"], 
     exports: '$' 
    }, 
    'underscore': { 
     exports: '_' 
    }, 
    'backbone': { 
     deps: ["underscore", "zepto"], 
     exports: 'Backbone' 
    }, 
    'bootstrap' : { 
     deps: ["zepto"] 
    }, 
    'marionette' : { 
     deps : ["backbone", "underscore", "zepto"], 
     exports: 'Marionette' 
    } 
    'socketio': { 
     exports: 'io' 
    }, 
    }, 
}); 

require(

    [ "zepto", 
    "underscore", 
    "backbone", 
    "less", 
    "marionette", 
    "MyApp", 
    "socketio", 
    "deferred", 
    ], 
    function($ , _, Backbone, less, Marionette, MyApp, io, Deferred) { 
    Deferred.installInto($); 

    }); 

我真正堅持在這裏,任何幫助將不勝感激

回答

1

我認爲推遲應視的Zepto,而不是其他的方式:

shim: { 
    'zepto':{ 
     exports: '$' 
    }, 
    'deferred': { 
     deps: ["zepto"], 
    }, 
0

我覺得'推遲'可能還需要一個出口聲明,以下爲我工作..

'deferred': { 
    'deps': ['jquery'], 
    'exports': 'Deferred' 
    },