Tag: backbone.js

kendo ui网格中的按钮在移动设备上不起作用

我有一个例子,使用Backbone.js添加了一个kendo ui网格。 在kendo ui网格中,我有一个删除行的按钮,但这些按钮在移动设备上不起作用。 如果我再次按下按钮,它有时会起作用。 为什么? 我在kendoGrid.columns中声明了这个按钮: { command: [{ name: “destroy”, text: “Remove”, className: “ob-delete” } 要删除行并在单击按钮时执行某些操作: $(document).on(“click”, “.grid tbody tr .ob-delete”, function (e) { var item = grid.dataItem($(this).closest(“tr”)); var check = confirm(“Delete”); if (check) { grid.removeRow($(this).closest(“tr”)); } }); 完整的例子 编辑: 我使用的是kendo ui版本:2012.3.1114

填充隐藏的表单字段

我的应用程序上的GET操作返回数组中的数据: Value”:[{“Id”:”6b7″,”Notes”:”testing”,”CreatedBy”:”User1″},{“Id”:”6b7″,”Notes”:”Testing 1″,”CreatedBy”:”User2″}] 我使用上面的方法来填充模板: **** Add Note Cancel {{#unless this.Value.length}} Notes do not exist. {{else}} Note Created By {{#each this.Value}} {{this.Notes}} {{this.CreatedBy}} {{/each}} {{/unless}} 如何填充隐藏的表单字段(Id)。 value = {{this.Value.Id}}不起作用,因为我们有一个数组。

过滤集合不起作用

我有一组模型采用布尔值interviewed ,我想过滤它们,以便我的视图显示具有此属性设置为true模型或具有此属性设置为false 。 在我的collections中,我有以下方法: var ResumeCollection = Backbone.Collection.extend({ filterActive: function () { var active = this.where({interviewed: false}); return active; }, filterInterviewed: function () { var interviewed = this.where({interviewed: true}); return interviewed; } }); 在我看来,我有以下几点: var ResumeList = Backbone.View.extend({ events: { ‘click #active’: ‘showActive’, ‘click #interviewed’: ‘showInterviewed’ }, initialize: function () { this.collection = new ResumeCollection(); […]

Backbonejs查看自我模板replaceWith和事件

我正在使用bbjs开发我的第一个应用程序,经过10个教程和无穷无尽的资源我试图想出我的代码设计。 我问有什么是视图和模板的最佳实践。 还有一个我正在努力解决的事件问题。 据我了解,视图是负责一个元素及其内容(和其他子视图)。 对于可管理,可测试等的代码,元素/模板将在创建时传递给视图。 在我的应用程序Imho中,视图应该包含模板,因为可见元素具有许多“状态”和每个状态的不同模板。 当状态发生变化时,我认为最好创建一个新视图,但是,视图是否可以使用新元素更新自身? App.Box = Backbone.Model.extend({ defaults: function() { return { media: “http://placehold.it/200×100”, text: “empty…”, type: “type1” }; } }); App.BoxView = Backbone.View.extend({ template: {}, templates: { “type1”: template(‘appboxtype1’), “type2”: template(‘appboxtype2’) }, events: { ‘click .button’: ‘delete’ }, initialize: function(options) { this.listenTo(this.model, ‘change’, this.render); this.listenTo(this.model, ‘destroy’, this.remove); this.render(); }, render: function() […]

在真实设备上的cordova app请求中出现net :: ERR_CONNECTION_TIMED_OUT错误

我有一个在Chrome浏览器和(genymotion)模拟器上运行良好的应用程序。 但是,如果我在智能手机上运行它,每个服务器请求(post,get,put)都会给出结果: Failed to load resource: net::ERR_CONNECTION_TIMED_OUT 我的设置: cordova:5.2.0 config.xml文件: jQuery的: $.support.cors=true; 我的要求:(我也用骨干做了同样的结果) $scope.loginRequestObject = $scope.getLoginObject(); $.ajax({ url : $scope.baseUrl + “/myTable”, type : ‘post’, contentType : ‘application/json; charset=utf-8’, scriptCharset : “utf-8”, data : JSON.stringify($scope.loginRequestObject), dataType : ‘json’, fail : function(a,b,c){ console.log(a); console.log(b); console.log(c); }, success: function(a,b,c){ console.log(a); console.log(b); console.log(c); }); 我通过导出和运行(cordova运行android)运行我的应用程序,我的手机有无线连接。

jQuery IE9-10:无法获取undefined或null引用的属性替换

我正在开发一个包含以下库的页面; jQuery(1.7.2)(旧版本因为依赖性问题,但已经尝试过1.9.1,并没有解决问题)。 骨干(1.1.0) lodash(2.4.1) modernizr(2.7.1) gsap(1.17.0) 该页面使用canvas和gsap进行动画制作。 在IE11,Chrome,Safari,Firefox和IE8(IE8禁用动画)中一切都很好用,但IE9和10只是在控制台上抛出此错误 无法获取未定义或空引用的属性’replace’ 引用的行在jquery.js ,第622行,这是此代码中的return语句: // Convert dashed to camelCase; used by the css and data modules // Microsoft forgot to hump their vendor prefix (#9572) camelCase: function( string ) { return string.replace( rmsPrefix, “ms-” ).replace( rdashAlpha, fcamelCase ); }, 我无法弄清楚如何确定我的代码的哪个部分导致这个jQuery代码触发,所以我不确定我的问题可能是什么。 有谁知道解决这个问题? 或者,我如何查看我的代码的哪个部分导致此jquery代码触发(使用IE开发工具)?

Backbone / Marionette CollectionView – 渲染内部模板?

我使用Backbone / Marionette / Moustache很好地渲染了一个集合。 所以PersonModel和PersonView工作正常。 PersonView有一个名为PersonTemplate的小胡子模板,由我的PeopleCollection和PeopleCollectionView完美加载,并在默认tagname: “div”内呈现。 但是,我想在另一个模板中渲染这个集合,所以我可以在那里放置一些标题。 现在它基本上是: John Dave 但我希望它是: People John Dave 我知道我可以在事后用jQuery添加这些项目,但我希望避免这种情况,因为我的实际CollectionTemplate比这里给出的例子复杂得多。

Backbone Paginator Collection不会在重置时触发渲染

我有一个Backbone Paginator系列: var ExercisesCollection = Backbone.Paginator.requestPager.extend({ model: ExerciseModel, paginator_core: { url: “/exercises” }, paginator_ui: { firstPage: 1, currentPage: 1, perPage: 10, totalPages: 10 }, server_api: { “filter”: “”, “categories”: “”, “top”: function() { return this.perPage; }, “skip”: function() { return this.currentPage * this.perPage; } }, parse: function (response) { this.totalPages = response.meta.totalPages; return response.data; } […]

Backbone.js将此绑定到$ .each

我正在使用backbonejs并在我拥有的方法中: $.each(response.error, function(index, item) { this.$el.find(‘.error’).show(); }); 但是,因为它是$.each , this.$el是未定义的。 我有_.bindAll(this, ‘methodName’) ,它将在每个之外工作。 那么,现在我需要绑定它吗? 任何帮助都会很棒! 谢谢

模板中的下划线条件

这是我的模板: var tmpl = _.template(‘< class=”” ></>’); 我将使用此模板渲染的一些对象没有设置elementClass属性。 我试图使用_.has以便模板只尝试打印定义了elementClass对象的属性,但我没有成功。 控制台错误仅表明未设置elementClass ,可能是因为条件语句无法正常工作。 我知道这是一个简单的问题,但我似乎无法解决它 – 如何在这样的语句中使用条件来检测没有设置某些属性的对象?