Greg Hinch![]()
Featured ItemProvides a simple way to associate a DataSource with a ModelList. The DataSource "response" event will automatically insert the response data into the ModelList. By default it will replace the content of the ModelList, and via a single attribute it can "stack" the data as well
Simply define a Model, ModelList, and a DataSource, and plug the ModelList with the DataSource.
<script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2012.01.04-22-09'
}).use('gallery-modellist-datasource', function(Y) {
var CustomModel = Y.Base.create('custom-model', Y.Model, [], {}, {
ATTRS : {
foo : {},
bar : {}
}
});
var ml = new Y.ModelList({model : CustomModel});
var ds = new Y.DataSource.IO({source : '/path/to/data?'});
ml.plug(Y.Plugin.ModelListDataSource, {
source : ds,
});
ds.sendRequest({request : "baz=boo&zul=blah"}) // on response the ModelList will be updated
});
© 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