Hello M Project team,
I am making a custom view using jquery mobile collapsible set. But i am unable to use the content binding property can any body help me my custom view code is pasted :
M.CollapsibleListView = M.View.extend({
type:'M.CollapsibleListView',
jsonData:null,
dataLength:4,
render:function() {
this.html = '<div id="'+
this.id+'"';
this.html += 'data-role="collapsible-set"';
this.html += 'data-theme="b"';
this.html += 'data-content-theme="c">';
this.html += this.renderCollapsible();
this.html += '</div>';
return this.html;
},
renderUpdate:function() {
$('#'+
this.id).html(this.value)
this.render();
},
theme:function() {
if($('#'+
this.id).html()) {
this.log('collapsible view on dom')
}else {
this.log('collapsible view not on dom')
}
},
style:function() {
var styleHtml = '';
if(this.cssClass) {
styleHtml += 'class="'+this.cssClass+'"';
}
return styleHtml;
},
//private methods which are called by the above framework callbacks
renderCollapsible:function() {
var titles = this.getTitleArray()
if(titles.length <= 0) {
return ''
}
var collapsibleHtml = "";
for(var i = 0; i < titles.length; i++) {
collapsibleHtml += '<div id="'+
this.id+'"';
collapsibleHtml += 'data-role="collapsible"';
collapsibleHtml += 'data-theme="b"';
collapsibleHtml += 'data-content-theme="c">';
collapsibleHtml += '<h2>';
collapsibleHtml += titles[i];
collapsibleHtml += '</h2>';
collapsibleHtml += this.renderListView();
collapsibleHtml += '</div>'
}
return collapsibleHtml
},
renderListView:function() {
var listViewHtml = '<ul data-role="listview">'
for(var i =0; i<this.dataLength; i++) {
var element = "Element_"+i;
listViewHtml += '<li>';
listViewHtml += '<a>'
listViewHtml += element;
listViewHtml += '</a>'
listViewHtml += '</li>'
}
listViewHtml += '</ul>'
return listViewHtml
},
getTitleArray:function() {
var titleArray = [];
if(this.value) {
var titleContent = this.value;
this.log('titleContent = '+titleContent.length)
for(var i =0 ; i <titleContent.length; i++) {
var title = titleContent[i].title
titleArray.push(title);
}
}
return titleArray;
},
getListDataArray:function() {
},
log:function(msg) {
M.Logger.log('Collapsible Log = '+msg);
}
});
Thanks,
Gargi