首页 \ 问答 \ Backbone,Marionette无法识别ItemView:undefined不是一个函数(Backbone, Marionette not recognizing ItemView: undefined is not a function)

Backbone,Marionette无法识别ItemView:undefined不是一个函数(Backbone, Marionette not recognizing ItemView: undefined is not a function)

我不明白为什么我的ItemView上出现了这个错误。

这是我的main.js

require.config({
    baseUrl: '/',
    paths: {

        jquery: 'scripts/lib/jquery/jquery.min',
        backbone: 'scripts/lib/backbone/backbone.min',
        underscore: 'scripts/lib/underscore/underscore-min',

        //Core Libraries
        marionette: 'scripts/lib/marionette/marionette.min',
        text: 'scripts/lib/text/text',
        async :'scripts/lib/async'
    },
    shim: {
        jquery: {
            exports: '$'
        },
        underscore: {
            exports: '_'
        },
        backbone: {
            deps: [ 'underscore', 'jquery' ],
            exports: 'Backbone'
        },
        marionette : {
            deps : ['jquery', 'underscore', 'backbone'],
            exports : 'Marionette'
        }
    }
});

require([
    'jquery',
    'underscore',
    'backbone',
    'marionette'
], function () {

    // create the app
    var App = new Marionette.Application();

    App.addRegions({
        map : '#Map'
    });


    App.addInitializer( function() {
        var self = this;
        require(['scripts/views/map']
        , function(MapView){
            self.map.show( new MapView() );
        });
    });

    App.start();

    window.App = App;
});

那么这是我的maps.js

define([
    'jquery',
    'underscore',
    'text!scripts/templates/map.html',
    'async!https://maps.googleapis.com/maps/api/js?v=3&sensor=true'
], function($, _, mapTemplate) {

    var MapView = Marionette.ItemView.extend({

        template: _.template( mapTemplate ),

        ui:  {
            mapContainer: '#map-container' 
        },

        onRender: function() {
            var self = this;

            var mapOptions = {
                zoom: 8,
                center: new google.maps.LatLng(-34.397, 150.644),
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };

            var map = new google.maps.Map(this.ui.mapContainer, mapOptions);

        }
    });

    return MapView;
});

我是骨干和牵线木偶的新手所以我不知道为什么我会得到以下错误:

未捕获的TypeError:undefined不是此行的函数:

self.map.show( new MapView() );

I do not understand why I have been getting this error on my ItemView.

Here is my main.js

require.config({
    baseUrl: '/',
    paths: {

        jquery: 'scripts/lib/jquery/jquery.min',
        backbone: 'scripts/lib/backbone/backbone.min',
        underscore: 'scripts/lib/underscore/underscore-min',

        //Core Libraries
        marionette: 'scripts/lib/marionette/marionette.min',
        text: 'scripts/lib/text/text',
        async :'scripts/lib/async'
    },
    shim: {
        jquery: {
            exports: '$'
        },
        underscore: {
            exports: '_'
        },
        backbone: {
            deps: [ 'underscore', 'jquery' ],
            exports: 'Backbone'
        },
        marionette : {
            deps : ['jquery', 'underscore', 'backbone'],
            exports : 'Marionette'
        }
    }
});

require([
    'jquery',
    'underscore',
    'backbone',
    'marionette'
], function () {

    // create the app
    var App = new Marionette.Application();

    App.addRegions({
        map : '#Map'
    });


    App.addInitializer( function() {
        var self = this;
        require(['scripts/views/map']
        , function(MapView){
            self.map.show( new MapView() );
        });
    });

    App.start();

    window.App = App;
});

then here is my maps.js

define([
    'jquery',
    'underscore',
    'text!scripts/templates/map.html',
    'async!https://maps.googleapis.com/maps/api/js?v=3&sensor=true'
], function($, _, mapTemplate) {

    var MapView = Marionette.ItemView.extend({

        template: _.template( mapTemplate ),

        ui:  {
            mapContainer: '#map-container' 
        },

        onRender: function() {
            var self = this;

            var mapOptions = {
                zoom: 8,
                center: new google.maps.LatLng(-34.397, 150.644),
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };

            var map = new google.maps.Map(this.ui.mapContainer, mapOptions);

        }
    });

    return MapView;
});

I'm new to backbone and marionette so I am not sure why I am getting the error of:

Uncaught TypeError: undefined is not a function on this line:

self.map.show( new MapView() );

原文:https://stackoverflow.com/questions/18832613
更新时间:2021-12-14 15:12

最满意答案

我已经通过复制粘贴方法解决了这个问题。 asmxMVC控制器,默认情况下是异步的。 现在我可以使用与.asmx相同的链接调用这些方法。


I've solved the problem by copy-pasting methods from .asmx to MVC controller, which is asynchronous by default. I can now call those methods with same link as from .asmx.

相关问答

更多
  • 与VS2015正式兼容的CGAL的第一个版本将是CGAL 4.7。 似乎新版本的微软在编译它之前接受的有效C ++代码时遇到了一些问题。 这解释了为什么CGAL(或之前的版本)的4.6版本与该新编译器存在一些编译问题。 The first version of CGAL officially compatible with VS2015 will be CGAL 4.7. It seems that the new version of the Microsoft has some issues compi ...
  • 未能升级VS2015的nuget 这个问题应该是核心visual studio可扩展性中的一个错误或问题。 这不是NuGet特定的问题。 它通常与诸如反病毒或加密服务等相关 。 我想在这里提供一些故障排除: 以管理员身份登录到计算机,并使用管理员启动Visual Studio。 检查您的计算机是否安装了McAfee Endpoint Encryption full-disk encryption product ,而不是防病毒软件。 如果是,则应该从全盘加密中排除devenv.exe和VSIXInstall ...
  • typeof(Object).GetMethods() 你要求所有的类型object的方法 你需要调用你想获得方法的类型的GetMethods()。 so i figured out how to get what i wanted it goes something like this [SecurityPermissionAttribute(SecurityAction.Demand, Unrestricted = true)] internal static void LoadWebService( ...
  • 看起来问题不完全在于框架,它可能是您用于序列化的类导致它。 替换整个序列化代码如下。 这种不和解决了这个问题。 XmlSerializer xsSubmit = new XmlSerializer(typeof(MyObject)); var subReq = new MyObject(); StringWriter sww = new StringWriter(); XmlWriter writer = XmlWriter.Create(sww); xsSubmit.Serialize(writer, s ...
  • 我已经通过复制粘贴方法解决了这个问题。 asmx到MVC控制器,默认情况下是异步的。 现在我可以使用与.asmx相同的链接调用这些方法。 I've solved the problem by copy-pasting methods from .asmx to MVC controller, which is asynchronous by default. I can now call those methods with same link as from .asmx.
  • 问题是我的现有项目有mvc版本5,但新测试项目有更新的版本。 一切都很好。 当我使用Nuget时,我没注意到版本不同。 我认为现在是我将所有项目更新到最新版MVC的好时机。 The issue was that my existing project had mvc version 5 but the new test project had a newer version. All good now. I didn't notice when I was using Nuget that the vers ...
  • 您可以尝试使用以下链接中描述的方法。 http://www.mindfiresolutions.com/ColdfusionMaking-a-call-to-a-Web-Service-with-complex-object-as-input-parameter-1228.php You can try with the method described in the below link. http://www.mindfiresolutions.com/ColdfusionMaking-a-call-t ...
  • 这只是一个建议,但我不认为它与缓存有某种关系。 可能的问题是权限问题或条件问题。 我的意思是,如果您在以某个用户身份登录CRM时创建了联系人,但尝试在其他CRM用户下检索以前创建的联系人。 或者可能是您添加到条件列表中的其他列,可能其中的某些列没有您认为存在的值。 solved: by using Retrieve() instead of RetrieveMultiple() I get the contact at once. this means that by searching for the n ...
  • 我通过安装Windows SDK得到了它的工作。 首先我安装了Windows 10 SDK,但没有工作。 其次我安装了Windows 7 SDK,它也没用。 最后,我推出了VS2015卸载程序,我选择修改添加WINDOWS 8.1 SDK功能,我使用他们的VS2015安装程序安装它然后就可以了。 我认为的原因是它的注册表项,但我不想花更多的时间在它上面,Windows SDK 8.1解决了这个问题。 I got it work by installing Windows SDK. First I insta ...
  • 发布并获取! 该服务正在侦听不同的HTTP谓词并相应地做出响应。 按下Invoke会向服务发送POST消息,同时在栏中键入它会向服务发送GET消息。 使用以下命令更改查询:type:“GET”,您将看到。 POST and GET! The service is listening for different HTTP verbs and responding accordingly. Pressing the Invoke sends a POST message to the service while ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)