我得到的错误来自 onShow 函数的最后一行:
//modalregion: shows a modal detail view in bootstrap modal
var ModalRegion = Marionette.Region.extend({
el: "#modal",
onShow : function(view) {
view.on("close", this.hideModal,this);
this.$el.modal('show'); //<- **throws TypeError: Object [object Object] has no method 'modal'**
},
hideModal: function() {
this.$el.modal('hide'); // bootstrap modal
}
});
我看到其他帖子有相同形式的错误 Object [object Object] has no method 'XXXX'
他们的解决方案是“停止加载 jquery 两次”。我正在使用 require.js,所以这不应该发生,但我检查了 Crome Dev 工具上的 Network 选项卡,没有加载两次。
this.$el 在调试器中定义,但不使用 modal 作为函数:
this.$el: jQuery.fn.jQuery.init
0: div#modal
context: #document
length: 1
selector: "#modal"
...snip...
load: function ( url, params, callback ) {
map: function ( callback ) {
mousedown: function ( data, fn ) {
mouseenter: function ( data, fn ) {
mouseleave: function ( data, fn ) {
mousemove: function ( data, fn ) {
mouseout: function ( data, fn ) {
mouseover: function ( data, fn ) {
mouseup: function ( data, fn ) {
next: function ( until, selector ) {
有没有我错过的步骤?
谢谢,
安德鲁