2013-12-16 31 views
6

Şirketim için jquery, backbonejs, underscorejs ve bootstrap kullanıyorum. Bazen bu hatayı kromda aldım.Bootstrap - Yakalanmamış TypeError: undefined özelliği 'fn' okunamıyor

Uncaught TypeError: Cannot read property 'fn' of undefined

Benim pul benim main.js

require.config({ 
paths: { 
    jquery: 'libs/jquery/jquery', 
    underscore: 'libs/underscore/underscore', 
    backbone: 'libs/backbone/backbone', 
    backboneeventbinder: 'libs/backbone.eventbinder.min', 
    bootstrap: 'libs/bootstrap', 
    jquerytablesorter: 'libs/tablesorter/jquery.tablesorter', 
    tablesorter: 'libs/tablesorter/tables', 
    ajaxupload: 'libs/ajax-upload', 
    templates: '../templates' 
}, 
shim: { 
    'backbone': { 
     deps: ['underscore', 'jquery'], 
     exports: 'Backbone' 
    }, 
    'underscore': { 
     exports: '_' 
    }, 
} 
}); 
require(['app', ], function(App) { 
    App.initialize(); 
}); 

Zaten jquery, underscorejs ve backbone.js için .noConflict() eklemek de böyledir. Benim krom enter image description here

Onun önyükleyebilmek ilgili tür benzeri dan

Benim app.js

// Filename: app.js 
define(['jquery', 'underscore', 'backbone', 'backboneeventbinder', 'bootstrap', 'ajaxupload', 'router', // Request router.js 
], function($, _, Backbone, Bootstrap, Backboneeventbinder, Ajaxupload, Router) { 
    $.noConflict(); 
    _.noConflict(); 
    Backbone.noConflict(); 
    var initialize = function() { 
      Router.initialize(); 
     }; 
    return { 
     initialize: initialize 
    }; 
}); 

Bu görüntü var.

Çok önceden teşekkürler.

+0

'noConflict' nasıl kullanılır? –

+0

Bu [cevap] (http://stackoverflow.com/a/11184070/122005) belki de yararlı olabilir – chridam

cevap

19

Bootstrap'ten önce jQuery yüklemem gerekiyor.

require.config({ 
    paths: { 
     jquery: 'libs/jquery/jquery', 
     underscore: 'libs/underscore/underscore', 
     backbone: 'libs/backbone/backbone', 
     bootstrap: 'libs/bootstrap', 
     jquerytablesorter: 'libs/tablesorter/jquery.tablesorter', 
     tablesorter: 'libs/tablesorter/tables', 
     ajaxupload: 'libs/ajax-upload', 
     templates: '../templates' 
    }, 
    shim: { 
     'backbone': { 
      deps: ['underscore', 'jquery'], 
      exports: 'Backbone' 
     }, 
     'jquery': { 
      exports: '$' 
     }, 
     'bootstrap': { 
      deps: ['jquery'], 
      exports: '$' 
     }, 
     'jquerytablesorter': { 
      deps: ['jquery'], 
      exports: '$' 
     }, 
     'tablesorter': { 
      deps: ['jquery'], 
      exports: '$' 
     }, 
     'ajaxupload': { 
      deps: ['jquery'], 
      exports: '$' 
     }, 
     'underscore': { 
      exports: '_' 
     }, 
    } 
}); 
require(['app', ], function(App) { 
    App.initialize(); 
}); 

Charm ile sabit!

+0

Önce jquery'yi yüklemeniz gerekiyor: D – Fiido93

0
//Call .noConflict() to restore JQuery reference. 

jQuery.noConflict(); OR $.noConflict(); 

//Do something with jQuery. 

jQuery("div.class").hide(); OR $("div.class").show(); 
+0

'noConflict()' aramayı belirtmeniz gerekir: jQuery'yi ekledikten hemen sonra. http://api.jquery.com/jQuery.noConflict/ – TheBronx

+0

çalışmıyor –

İlgili konular