두 번째로 나는이 질문을하고 있는데, 처음에는 텍스트가 이해하기 쉽지가 않아서 미안합니다. 다음은 개선 된 동일한 질문입니다.백본 (동기화) 업데이트 이벤트
나는 PageableCollection을 가지고 있는데, 문제없이 데이터가로드됩니다! 테이블의 라인 (backgrid, 백본의 확장 기능을 사용하고 있습니다)을 편집 할 수 있습니다 !! 하지만 편집 후 Enter 버튼을 누르면 아무 일도 일어나지 않습니다! 서버가 호출되지 않습니다. 서버에 대한 호출 AJAX를 기다리지 만 발생하지 않습니다.
동기화를 무시할 수있는 방법을 찾았지만 수정 후 "okay"또는 "error updating"이라고 말하고 싶습니다. 울부 짖는 소리
코드 :
var Territory = Backbone.Model.extend({});
var PageableTerritories = Backbone.PageableCollection.extend({
model: Territory,
url: "linhas/results",
state: {
pageSize: 9
},
mode: "client",
sync: function (method, model, options){
return Backbone.sync(method, model, options);
}
});
var pageableTerritories = new PageableTerritories(),
initialTerritories = pageableTerritories;
function createBackgrid(collection){
var columns = [{
name: "id", // The key of the model attribute
label: "ID", // The name to display in the header
editable: false, // By default every cell in a column is editable, but *ID* shouldn't be
// Defines a cell type, and ID is displayed as an integer without the ',' separating 1000s.
cell: Backgrid.IntegerCell.extend({
orderSeparator: ''
})
}, {
name: "name",
label: "Name",
// The cell type can be a reference of a Backgrid.Cell subclass, any Backgrid.Cell subclass instances like *id* above, or a string
cell: "string" // This is converted to "StringCell" and a corresponding class in the Backgrid package namespace is looked up
}, {
name: "pop",
label: "Population",
cell: "integer" // An integer cell is a number cell that displays humanized integers
}, {
name: "url",
label: "URL",
cell: "uri" // Renders the value in an HTML <a> element
}];
if ($(window).width() < 768){
//okendoken. removing URL-column for screens smaller than 768px
columns.splice(3,1)
}
var pageableGrid = new Backgrid.Grid({
columns: columns,
collection: collection,
footer: Backgrid.Extension.Paginator.extend({
//okendoken. rewrite template to add pagination class to container
template: _.template('<tr><td colspan="<%= colspan %>"><ul class="pagination"><% _.each(handles, function (handle) { %><li <% if (handle.className) { %>class="<%= handle.className %>"<% } %>><a href="#" <% if (handle.title) {%> title="<%= handle.title %>"<% } %>><%= handle.label %></a></li><% }); %></ul></td></tr>')
}),
className: 'table table-striped table-editable no-margin'
});
$("#table-dynamic").html(pageableGrid.render().$el);
}
그게 전부입니다! 공장! 고맙습니다 (: – Mauricionik