require.js'Backbone'仅限IE未定义

时间:2012-09-25 15:07:21

标签: internet-explorer backbone.js undefined require

网站适用于所有浏览器,但IE: SCRIPT5009:'Backbone'未定义

这里是main.js,它已经工作了几个小时,似乎符合所有API要求?

requirejs.config({
    paths: {
    //  "jquery" : "jquery-1.7.2.min",
        "jquery.json" : "jquery.json-2.3.min",
        "jquery.jtemplates" : "jquery-jtemplates",
        "jquery.nailthumb" : "jquery.nailthumb.1.1.min",
        "jquery.ui" : "jquery-ui-1.8.21.custom.min",
        "jquery.fileupload" : "jquery-fileupload/jquery.fileupload",
        "jquery.iframe-transport" : "jquery-fileupload/jquery.iframe-transport",
        "jquery.ui.widget" : "jquery-fileupload/vendor/jquery.ui.widget",
        "jquery.fancybox" : "jquery.fancybox",
        "handlebars" : "handlebars",
        "input" : "input",
        "validator" : "cars/modules/carsValidator",
        "backbone" : "backbone",
        "underscore": "underscore"

    },
    shim: {
        'jquery.jtemplates': {
            deps: ['jquery']
        },
            //exports: "jQuery.fn.setTemplate"
        //},
        'jquery.json': {
            deps: ['jquery'],
            exports: "JSON"
        },
        'jquery.nailthumb':{
            deps: ['jquery']
        },
        'jquery.iframe-transport':{
            deps: ['jquery']
        },
       'jquery.fancybox':{
            deps: ['jquery']
        },
        'input': {
            deps: ['jquery']
        },
        'backbone': {
            deps: ['jquery', 'underscore'],
            exports: "Backbone"
        },
        'underscore' :{
            exports: '_'
        }

    } 
});
requirejs(["jquery"], function($) {
    window.$ = $;
    if (typeof console == "undefined") {
        this.console = {log: function() {}};
    }
    //this will invoke the script for the page
    if (module){
        require([module], function(module){});
    }


});

和我的定义调用:

define(["jquery", "backbone"], function ($, backbone) {
    return backbone.Model.extend({
        update: function (message) {
            return this.type(message.type).message(message.message);
        },

        type: function (type) {
            if (type) {
                this.set({type: type});
                return this;
            }
            return this.get("type");

        },

        message: function (message) {
            if (message) {
                this.set({message: message});
                return this;
            }
            return this.get("message");
        }
    });
});

任何帮助都会很棒.... 感谢

1 个答案:

答案 0 :(得分:0)

我知道这不是你期望的解决方案,但我在IE10上遇到了同样的错误。 事情是,在较旧的ie版本(即9,8,7,6)它工作正常,所以我决定使用官方MS'hack' - X-UA-Compatible

只需将以下行添加到html的<head>部分:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />

希望它有所帮助!