Luke Smith![]()
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.
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info