- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我仍在尝试将过滤功能实现到 Backbone 络应用程序中,但仍然有错误。查看
define([
'underscore',
'backbone',
'collections/tables/TablesCollection',
'text!templates/tables/tablesTemplate.html',
'lunr',
'backgrid',
'backbone.paginator',
'backgrid-paginator',
'backgrid-filter',
], function(_, Backbone, TablesCollection, tablesTemplate, lunr, backgrid){
var TablesView = Backbone.View.extend({
el: document.getElementById("content"),
render: function() {
var tables = JSON.parse(localStorage.getItem('tables'));
var tablesCollection = new TablesCollection(tables);
this.el.innerHTML = _.template( tablesTemplate,{data : tablesCollection.toJSON()});
var columns = [{
name: "id",
label: "ID",
editable: false,
cell: Backgrid.IntegerCell.extend({
orderSeparator: ''
})
}, {
name: "title",
label: "Name",
cell: "string"
}, {
name: "seats",
label: "Seats",
cell: "string"
}, {
name: "location",
label: "Location",
cell: "string"
}, {
name: "date",
label: "Active",
cell: "activ",
editable: false,
},{
name: "dummy",
label: "Delete",
cell: "dele",
editable: false,
}];
var pageableGrid = new Backgrid.Grid({
columns: columns,
collection: tablesCollection
});
var $example2 = $("#example-2-result");
$example2.append(pageableGrid.render().el)
var paginator = new Backgrid.Extension.Paginator({
collection: tablesCollection
});
$("#example-2-pagi").append(paginator.render().el);
var clientSideFilter = new Backgrid.Extension.ClientSideFilter({
collection: clientTerritories,
placeholder: "Search in the browser",
fields: ['name'],
wait: 150
});
// $("#client-side-filter-example-result").prepend(clientSideFilter.render().el);
},
});
return TablesView;
});
路由器
define([
'underscore',
'backbone',
'models/table/TableModel',
'collections/tables/TablesCollection',
'views/tables/TablesView',
'lunr',
'backgrid',
'backbone.paginator',
'backgrid-paginator',
'backgrid-filter',
], function(_, Backbone, TableModel, TablesCollection, TablesView) {
if(localStorage.getItem('tables') == null){
var tables = [
{title: "Table 1", seats: "3", location: "venku", active:true, cls: "1cls"},
{title: "Table 2", seats: "3", location: "venku", active:true, cls: "2cls"},
{title: "Table 3", seats: "3", location: "venku", active:true, cls: "3cls"},
{title: "Table 4", seats: "3", location: "venku", active:true, cls: "4cls"},
{title: "Table 5", seats: "3", location: "venku", active:true, cls: "1cls"},
{title: "Table 6", seats: "3", location: "venku", active:true, cls: "2cls"},
{title: "Table 7", seats: "3", location: "venku", active:true, cls: "3cls"},
{title: "Table 8", seats: "3", location: "venku", active:true, cls: "4cls"},
{title: "Table 9", seats: "3", location: "venku", active:true, cls: "1cls"},
{title: "Table 10", seats: "3", location: "venku", active:false, cls: "2cls"},
{title: "Table 11", seats: "3", location: "venku", active:false, cls: "3cls"},
{title: "Table 12", seats: "3", location: "venku", active:false, cls: "4cls"},
];
localStorage.setItem('tables',JSON.stringify(tables));
}
var AppRouter = Backbone.Router.extend({
routes: {
'':'tables',
'tables':'tables',
}
});
var initialize = function(){
window.app_router = new AppRouter;
app_router.on('route:tables', function(table) {
var tablesView = new TablesView({model:{table:table}});
tablesView.render();
});
Backbone.history.start();
};
return {
initialize: initialize
};
});
收藏
define([
'underscore',
'backbone',
'models/table/TableModel',
'lunr',
'backgrid',
'backbone.paginator',
'backgrid-paginator',
'backgrid-filter',
], function(_, Backbone, TableModel){
var TablesCollection = Backbone.PageableCollection.extend({
model: TableModel,
//url: "",
state: {
pageSize: 5
},
mode: "client", // page entirely on the client side
});
return TablesCollection;
});
没有过滤器的表工作正常,但现在出现错误:未捕获类型错误:无法读取未定义的属性“扩展”
我不知道我做错了什么。感谢您的帮助。
最佳答案
Backgrid.js 中似乎存在一些依赖性问题
您需要定义 backgrid,以便 require JS 可以整理您的依赖关系。
define(["jquery", "underscore", "backbone", "backgrid"], factory);
请参阅下面的完整差异。
diff --git a/index.html b/index.html
index 9215493..8946227 100755
--- a/index.html
+++ b/index.html
@@ -22,4 +22,4 @@
</div>
</content>
</body>
-</html>
\ No newline at end of file
+</html>
diff --git a/js/libs/backgrid-filter.js b/js/libs/backgrid-filter.js
index 59e3012..c4d94af 100644
--- a/js/libs/backgrid-filter.js
+++ b/js/libs/backgrid-filter.js
@@ -509,4 +509,4 @@
});
-}));
\ No newline at end of file
+}));
diff --git a/js/libs/backgrid-paginator.js b/js/libs/backgrid-paginator.js
index 9a032e5..e7da301 100755
--- a/js/libs/backgrid-paginator.js
+++ b/js/libs/backgrid-paginator.js
@@ -8,7 +8,13 @@
(function (root, factory) {
// CommonJS
- if (typeof exports == "object") {
+
+ if (typeof define === 'function' && define.amd) {
+
+ // AMD. Register as an anonymous module.
+ define(["underscore", "backbone", "backgrid"], factory);
+ } else if (typeof exports == "object") {
+
module.exports = factory(require("underscore"),
require("backbone"),
require("backgrid"),
diff --git a/js/libs/backgrid.js b/js/libs/backgrid.js
index a3c7367..e493e84 100755
--- a/js/libs/backgrid.js
+++ b/js/libs/backgrid.js
@@ -9,7 +9,13 @@
(function (factory) {
require("backbone"),
require("backgrid"),
diff --git a/js/libs/backgrid.js b/js/libs/backgrid.js
index a3c7367..e493e84 100755
--- a/js/libs/backgrid.js
+++ b/js/libs/backgrid.js
@@ -9,7 +9,13 @@
(function (factory) {
// CommonJS
- if (typeof exports == "object") {
+
+ if (typeof define === 'function' && define.amd) {
+
+ // AMD. Register as an anonymous module.
+ define(["jquery", "underscore", "backbone", "backgrid"], factory);
+ }
+ else if (typeof exports == "object") {
module.exports = factory(module.exports,
require("underscore"),
require("backbone"));
@@ -20,6 +26,7 @@
"use strict";
+
/*
backgrid
http://github.com/wyuenho/backgrid
@@ -2982,4 +2989,4 @@ var Grid = Backgrid.Grid = Backbone.View.extend({
});
return Backgrid;
-}));
\ No newline at end of file
+}));
diff --git a/js/views/tables/TablesView.js b/js/views/tables/TablesView.js
index aca89af..ea14749 100755
--- a/js/views/tables/TablesView.js
+++ b/js/views/tables/TablesView.js
@@ -8,7 +8,7 @@ define([
'backbone.paginator',
'backgrid-paginator',
'backgrid-filter',
-], function(_, Backbone, TablesCollection, tablesTemplate, lunr, backgrid){
+], function(_, Backbone, TablesCollection, tablesTemplate, lunr, Backgrid){
var TablesView = Backbone.View.extend({
el: document.getElementById("content"),
render: function() {
关于javascript - Backgrid 过滤器在 Backbone 应用程序中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25840275/
我有以下格式的 json 对象: { properties:{ url:"http://..." } } 我想在 Backgr
friend 们好。我在我的项目中使用 backgrid。我想从 backgrid 中隐藏 Id 列。这是我的代码。 var columns = [ { name: "id", label: "Id"
我正在使用 backgrid 来显示表格。我想在表格标题上显示工具提示。 有人可以帮忙吗? 最佳答案 扩展 Backgrid.HeaderRow Backgrid.HeaderRow = Back
是否可以使用 BackGrid 通过格式化程序构建自定义 Cell,从隐藏列中组合值? var grid = new Backgrid.Grid({ columns: [ { name
我正在学习 Backbone.js 并使用 BackGrid 呈现数据并为最终用户提供一种在 Microsoft MVC 网站上编辑记录的方法。出于此测试网格的目的,我使用 vendor 模型。 Ba
(让我先说一下我是 Backbone 和 Backgrid 的新手。)我正在使用 Backgrid 和全选扩展,但我遇到了“捕获”我的包含/父 View 中全选触发的事件的问题。我想在主网格中选择一行
(让我先说一下我是 Backbone 和 Backgrid 的新手。)我正在使用 Backgrid 和全选扩展,但我遇到了“捕获”我的包含/父 View 中全选触发的事件的问题。我想在主网格中选择一行
在我的 GridView 中, 我在收集结束时插入一个新的主干模型(没有 id 的模型),在背景网格中插入一个新的空白行 我想将占位符放在该空白行的第一个输入单元格中。我在文档中找不到相同的但幸运的是
大家好,我正在使用 backgrid 来渲染我的表格。我不知道如何在列中添加元素。有人可以告诉我该怎么做吗? 最佳答案 查看此处的文档/api后:http://backgridjs.com/您可以通过
我的页面上有一个包含数据集合的 Backgrid View 。 Backgrid View 上方是另一个称为“过滤器”的 View ,它允许用户更改数据的日期范围,以便他们可以查看两个日期之间的结果。
我仍在尝试将过滤功能实现到 Backbone 络应用程序中,但仍然有错误。查看 define([ 'underscore', 'backbone', 'collections/
我想根据条件渲染一个具有可编辑和不可编辑行的网格。我可以通过设置颜色来区分这一点,但使其对于已删除的记录不可编辑会更有用。期待好的解决方案。 var DeletedRow = Backgrid.Row
var lunrFilter1 = new Backgrid.Extension.LunrFilter({ collection: pageableTerritories.fullCollecti
我正在尝试让 backgrid.js 的最基本示例正常工作。换句话说,这是一个我可以将源文件夹放入我的 xampp/htdocs 文件夹并运行而无需执行任何其他操作的示例。 我已经尝试了很多方法来运行
我正在使用 Backgrid 作为表格结构。现在,我必须添加具有编辑、查看、删除按钮和列标题“操作”的操作列。我不知道如何使用 Backgrid 来做到这一点。由于我们为一列提供了一个单元格,因此如何
谁能告诉我如何在单击按钮时将 Backgrid.js 表数据导出为 csv。我已经使用 backgrid.js 显示了一个表格。现在我想将数据导出为 csv 文件。 最佳答案 您可以使用 unders
您好,我想在我的网格中打印“未找到记录”,未找到任何内容或表格中有 0 行。现在我的网格在获取数据时显示结果,但在未获取数据时显示空网格。那么当没有记录时如何打印“未找到记录”? 最佳答案 在您的 B
已经实现的内容:我们有一个页面,其中 Backgrid 表是从数据库中的 table1 呈现的(工作正常),并且 Backgrid 中的大多数单元格都是可编辑的。单元格保持可编辑状态,以便现有详细信息
我正在使用 BackGrid.js 对我的数据表进行分页,但我在“左页”和“右页”图像上遇到了一个小问题,它们似乎没有为我呈现,所以我必须是缺少相关图像,或者我没有相关元素的相关 CSS, 我试图四处
我是一名优秀的程序员,十分优秀!