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
最满意答案
我已经通过复制粘贴方法解决了这个问题。
asmx
到MVC
控制器,默认情况下是异步的。 现在我可以使用与.asmx
相同的链接调用这些方法。I've solved the problem by copy-pasting methods from .
asmx
toMVC
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( ...
-
部署在.net framework 4.0上时asmx服务抛出错误(asmx service throwing error when deployed on .net framework 4.0)[2023-02-17]
看起来问题不完全在于框架,它可能是您用于序列化的类导致它。 替换整个序列化代码如下。 这种不和解决了这个问题。 XmlSerializer xsSubmit = new XmlSerializer(typeof(MyObject)); var subReq = new MyObject(); StringWriter sww = new StringWriter(); XmlWriter writer = XmlWriter.Create(sww); xsSubmit.Serialize(writer, s ... -
未找到VS2015 asmx方法(VS2015 asmx method not found)[2023-10-07]
我已经通过复制粘贴方法解决了这个问题。 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 ...