The Gallery is deprecated. No new Gallery components may be submitted, and modifying existing components is disabled. For more information please read the Gallery Deprecation blog post. This is a static snapshot of the Gallery for archive purposes.
See 19 more by this user. Created: 12/15/09
Last CDN Push: 01/13/10
Build Tag: gallery-2010.01.13-20
Project: YUI 3
License: YUI BSD
YUI Version: 3.3.0
Free for use.
Replaces the current Y.DataSchema namespace object with a class constructor. Does not impact the operation of other DataSchema modules. Allows a schema to be coupled with its appropriate parser implementation for convenient reuse rather than needing to pass a separately stored schema object to the static implemenations' apply(schema, data) method.
Before:
var schema = { ... };
var recs = Y.DataSchema.JSON.apply(schema, data);
var moreRecs = Y.DataSchema.JSON.apply(schema, data2);
With this module:
var parser = new Y.DataSchema({ type: 'json', schema: { ... } });
var recs = parser.apply(data);
var moreRecs = parser.apply(data2);
<script src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
YUI({
//Last Gallery Build of this module
gallery: 'gallery-2010.01.13-20'
}).use('io-base', 'gallery-dataschema-class', function(Y) {
var parser = new Y.DataSchema({
type: 'json',
schema: {
resultListLocator: 'recs',
resultFields: [
{ key: 'id' },
{ key: 'first_name' },
{ key: 'last_name' }
]
}
});
Y.io(url, { on: {
success: function (id, o) {
data = parser.apply(o.responseText);
Y.log(data.results.length);
}
}});
});
No forum posts for this module.
All code on this site is licensed under the BSD License unless stated otherwise.