new enyo.AjaxSource({name:'source'});
enyo.kind({
name:'clip.GroupCollection',
kind:'enyo.Collection',
source:'source',
model:"clip.VideoModel",
published: {
category: null,
},
categoryChanged: function() {
this.empty({destroy:true});
if(this.category =='home') {
return this.fetch();
}
},
options: { parse: true },
parse: function(data) {
return data && data.result;
},
getUrl: function() {
return "http://api.xxx.vn/app/home/get_groups?id=" + this.get("userid");
}
});
enyo.kind({
name:'clip.HomeContent',
kind:'FittableRows',
fit:true,
spotlight:'container',
components:[
{
kind:'moon.Button',content:'click',ontap:'tapped'
},
{
name:'clipNewest',
kind:'clip.ItemHome',
}
],
create:function(){
this.inherited(arguments);
this.set('collection',new clip.GroupCollection());
},
bindings:[
{
from:"collection",
to:"$.clipNewest.model",
transform:function(data){
console.log('transform data',this.collection);
if(this.collection && this.collection.length>0 && this.collection.at(0)){
console.log('newest',this.collection.at(0));
return this.collection.at(0);
}
}
}
],
tapped:function(){
console.log('tap');
this.collection.set('category','home');
}
});
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
i change binding by collection length and working now.
bindings:[ { from:"collection.length", to:"$.clipNewest.model", transform:function(data){ console.log('transform data',this.collection); if(this.collection && this.collection.length>0 && this.collection.at(0)){ console.log('newest',this.collection.at(0)); return this.collection.at(0); } } }, ]