我在骨干库中比较新.我正在尝试构建一个基于backbone + requirejs + jquery-mobile的移动应用程序.我可以使用现有的json本地文件填充我的集合.(将来可能来自远程服务器).现在我试图让这个集合只被调用一次,然后将它存储在localStorage中进行读取.为此,我试图使用这个适配器(https://github.com/jeromegn/Backbone.localStorage),但我不明白如何.
// models
define([
'underscore',
'backbone'
], function(_, Backbone) {
var AzModel = Backbone.Model.extend({
defaults: {
item: '',
img:"img/gi.jpg"
},
initialize: function(){
}
});
return AzModel;
});
// Collection
define(['jquery', 'underscore', 'backbone', 'models/az'], function($, _, Backbone, AzModel) {
var AzCollection = Backbone.Collection.extend({
localStorage: new Backbone.LocalStorage("AzStore"), // Unique name within your app.
url : "json/azlist.json",
model : AzModel
parse : function(response) {
return response;
}
});
return AzCollection;
});
define(['jquery', 'underscore', 'backbone', 'collections/azlist', 'text!templates/karate/az.html'], …Run Code Online (Sandbox Code Playgroud) 我在"自定义编辑模式"中使用jqgrid时遇到问题.我正确地构建了网格,并为每行编辑/保存/取消/删除按钮.对于每个按钮,我将一个函数绑定到每个操作(保存,保存等).我现在的问题是,当试图检查字段是否有效时,执行验证功能并触发错误对话框,但是值已提交到数据库,并且该行不会保持在"编辑模式",以便用户更正错误.
我也想知道是否可以抑制内置错误对话框,只是突出显示错误的字段.错误消息将显示为div中的摘要.
感谢您的关注
我的相关代码示例
// function to retrieve data to jqgrid
getList();
// grid configuration
$("#list").jqGrid({
datatype: "local",
width: 465,
colNames: ["ID", "Descrição", ""],
colModel: [
{ name: "id", index: "id", sorttype: "int", hidden: true },
{ name: "descr", index: "descr", editable: true, edittype: "text", editrules: { custom: true, custom_func: checkvalid }
},
{ name: "action", index: "action", sortable: false, width: 90, search: false} // Botões
],
loadtext: 'A carregar...',
rowNum: 20,
rowList: [20, 40, 80, 100, 200],
ignoreCase: true, …Run Code Online (Sandbox Code Playgroud)