⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jsonpathstore.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 2 页
字号:
				return true;			}		},		{			name: "jsonPathStore Feature: override createLabel", 			runTest: function(t) {				var createLabel = function(item){					return item[this.labelAttribute[0]] + " By " + item[this.labelAttribute[1]];				};				var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, labelAttribute: ["title", "author"], createLabel: createLabel});				var result = store.fetch("$.store.book[0]")[0]; 					doh.assertEqual('Sayings of the Century By Nigel Rees',store.getLabel(result));				return true;			}		},		{			name: "jsonPathStore Feature: autoIdentity", 			runTest: function(t) {				var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, idAttribute: "_id"});				var result = dojo.toJson(store.fetch("$.store.book[0]")[0]); 					var success=dojo.toJson( {"category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95, "_meta": {"path": "$['store']['book'][0]", "autoId": true, "referenceIds": ["_ref_1"]}, "_id": "_auto_3"});				doh.assertEqual(success,result);				return true;			}		},		{			name: "jsonPathStore Feature: autoIdentity [clean export removing added id attributes in addition to meta]", 			runTest: function(t) {				var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, idAttribute: "_id"});				//do a search to popuplate some of the itesm with autoId data				var result = store.fetch("$.store.book[0]"); 					result = store.dump({cleanMeta: true});				doh.assertEqual(dojox.data.tests.testData,result);				return true;			}		},		{			name: "IdentityAPI: getIdentity(item)", 			runTest: function(t) {				var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, idAttribute: "_id"});				var data= store.fetch("$.store.book[0]")[0]; 					var result= store.getIdentity(data);				var success="_auto_3";				doh.assertEqual(success,result);				return true;			}		},		{					name: "IdentityAPI: fetchItemByIdentity(item) [SYNC_MODE]", 			runTest: function(t){				var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, idAttribute: "_id"});				var data= store.fetch("$.store.book[0]")[0]; 					var id = store.getIdentity(data);				var result = dojo.toJson(store.fetchItemByIdentity({identity:id}));				var success = dojo.toJson(data);						doh.assertEqual(success,result);				return true;			}		},		{					name: "jsonPathStore Feature: byId(item) [fetchItemByIdentity alias] [SYNC_MODE]", 			runTest: function(t){				var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, idAttribute: "_id"});				var data= store.fetch("$.store.book[0]")[0]; 					var id = store.getIdentity(data);				var result = dojo.toJson(store.byId({identity:id}));				var success = dojo.toJson(data);						doh.assertEqual(success,result);				return true;			}		},		{			name: "IdentityAPI: fetchItemByIdentity(id) single Item [ASYNC_MODE]",			timeout: 1000,			runTest: function(datastore, t){				//      summary:				//              Simple test of the fetchItemByIdentity function of the store.				var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, indexOnLoad: true});				var d = new doh.Deferred();				var query = {query: "$.store.book[0]", mode: dojox.data.SYNC_MODE};				var data = store.fetch(query)[0];				var id = store.getIdentity(data);				function onItem(item){					doh.assertTrue(store.isItem(item));					doh.assertEqual(data["author"], item["author"]);					d.callback(true);				}				function onError(errData){					t.assertTrue(false);					d.errback(errData);				}				store.fetchItemByIdentity({identity: id, onItem: onItem, onError: onError});				return d; // Deferred			}		},		{			name: "IdentityAPI: getIdentityAttributes(item) ", 			runTest: function(t) {				var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, idAttribute: "_id"});				var data= store.fetch("$.store.book[0]")[0]; 					var result = dojo.toJson(store.getIdentityAttributes(data));				var success = '["_id"]';				doh.assertEqual(success,result);				return true;			}		},		{			name: "WriteAPI: newItem(item) add to store root.",			runTest: function(t) {				var original = dojox.data.tests.testData;				var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, idAttribute: "_id"});				var testObject = {					propA: "foo",					propB: "bar"				}				var testObject2 = {					propA: "foo",					propB: "bar"				}				var newItem = store.newItem(testObject);				doh.assertTrue(store.isItem(newItem));					newItem = store.newItem(testObject2);				doh.assertTrue(store.isItem(newItem));					return true; 			}		},		{			name: "WriteAPI: newItem(item) no idAttribute on data item, added only with pInfo",			runTest: function(t) {				var original = dojox.data.tests.testData;				var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE});				var parentItem = store.fetch("$.store.book[0]")[0];				var testObject = {					propA: "foo",					propB: "bar"				}				var newItem = store.newItem(testObject,{parent: parentItem, attribute: "TEST_PROPERTY"});				doh.assertTrue(store.isItem(newItem));					return true; 			}		},		{			name: "WriteAPI: newItem(item) given id, no parent Attribute",			runTest: function(t) {				var original = dojox.data.tests.testData;				var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, idAttribute: "_id"});				var parentItem = store.fetch("$.store.book[0]")[0];				var testObject = {					_id: "99999",					propA: "foo",					propB: "bar"				}				var newItem = store.newItem(testObject,{parent: parentItem});				doh.assertTrue(store.isItem(newItem));					return true; 			}		},		{			name: "WriteAPI: newItem(item) given id and  parent Attribute",			runTest: function(t) {				var original = dojox.data.tests.testData;				var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, idAttribute: "_id"});				var parentItem = store.fetch("$.store.book[0]")[0];				var testObject = {					_id: "99999",					propA: "foo",					propB: "bar"				}				var newItem = store.newItem(testObject,{parent: parentItem, attribute: "TEST"});				doh.assertTrue(store.isItem(newItem));					return true; 			}		},		{			name: "WriteAPI: newItem(item) adding to an array",			runTest: function(t) {				var original = dojox.data.tests.testData;				var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, idAttribute: "_id"});				var parentItem = store.fetch("$.store")[0];				var testObject = {					_id: "99999",					propA: "foo",					propB: "bar"				}				var newItem = store.newItem(testObject,{parent: parentItem, attribute: "book"});				doh.assertTrue(store.isItem(newItem));					return true; 			}		},		{			name: "WriteAPI: setValue(item, value)",			runTest: function(t) {				var original = dojox.data.tests.testData;				var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, indexOnLoad: true, idAttribute: "_id"});				var item = store.fetch("$.store")[0];				var snapshot = store.dump({clone:true, cleanMeta: false, suppressExportMeta: true});				store.setValue(item, "Foo", "Bar");				doh.assertEqual(store._data.store.Foo, "Bar");				doh.assertTrue(store._data.store._meta.isDirty);				store.save();				doh.assertFalse(store._data.store._meta.isDirty);				return true; 			}		},		{			name: "WriteAPI: setValues(item, value)",			runTest: function(t) {				var original = dojox.data.tests.testData;				var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, indexOnLoad: true, idAttribute: "_id"});				var item = store.fetch("$.store")[0];				var snapshot = store.dump({clone:true, cleanMeta: false, suppressExportMeta: true});				store.setValues(item, "Foo", ["Bar", "Diddly", "Ar"]);				doh.assertEqual(store._data.store.Foo[0], "Bar");				doh.assertEqual(store._data.store.Foo.length, 3);				doh.assertTrue(store._data.store._meta.isDirty);				store.save();				doh.assertFalse(store._data.store._meta.isDirty);				return true; 			}		},		{			name: "WriteAPI: unsetAttribute(item, attribute)",			runTest: function(t) {				var original = dojox.data.tests.testData;				var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, indexOnLoad: true, idAttribute: "_id"});				var item = store.fetch("$.store")[0];				var snapshot = store.dump({clone:true, cleanMeta: false, suppressExportMeta: true});				store.setValues(item, "Foo", ["Bar", "Diddly", "Ar"]);				doh.assertEqual(store._data.store.Foo[0], "Bar");				doh.assertEqual(store._data.store.Foo.length, 3);				doh.assertTrue(store._data.store._meta.isDirty);				store.save();				doh.assertFalse(store._data.store._meta.isDirty);				store.unsetAttribute(item,"Foo");				doh.assertFalse(item.Foo);				doh.assertTrue(store._data.store._meta.isDirty);				store.save();				doh.assertFalse(store._data.store._meta.isDirty);				return true; 			}		},		{			name: "WriteAPI: revert()",			runTest: function(t) {				var original = dojox.data.tests.testData;				var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, indexOnLoad: true, idAttribute: "_id"});				var item = store.fetch("$.store")[0];				var snapshot = store.dump({clone:true, cleanMeta: false, suppressExportMeta: true});				store.setValues(item, "Foo", ["Bar", "Diddly", "Ar"]);				doh.assertEqual(store._data.store.Foo[0], "Bar");				doh.assertEqual(store._data.store.Foo.length, 3);				doh.assertTrue(store._data.store._meta.isDirty);				store.revert();				doh.assertFalse(store._data.store._meta.isDirty);				doh.assertFalse(store._data.store.Foo);				return true; 			}		}	]);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -