I was trying figure out the how to make the script work for my array, but I came to a point where I’ve given up. This is probably too simple to some people here, for I’m only a newbie. Here’s my page code…
<div class="page-content ptr-content" data-ptr-mousewheel="true" @ptr:refresh="loadMore">
<div class="ptr-preloader">
<div class="preloader"></div>
<div class="ptr-arrow"></div>
</div>
<div class="list media-list">
<ul>
{{#each items}}
<li class="item-content">
<div class="item-media"><img src="https://cdn.framework7.io/placeholder/abstract-88x88-{{picUrl}}.jpg" width="50"/></div>
<div class="item-inner">
<div class="item-title-row">
<div class="item-title"><a href="/{{itemHref}}/" class="link" taget="_blank">{{titleMain}}</a></div>
</div>
<div class="item-subtitle">{{titleSub}}</div>
</div>
</li>
{{/each}}
</ul>
</div>
</div>
Below is my script:
return {
data: function () {
return {
myArrays: [
{
titleMain: 'Title 1',
picUrl: '1',
titleSub: 'titleSub 1',
itemHref: 'href1'
},
{
titleMain: 'Title 2',
picUrl: '2',
titleSub: 'titleSub 2',
itemHref: 'href2'
},
],
};
},
methods: {
loadMore: function (e, done) {
var self = this;
var $ = self.$$;
setTimeout(function () {
self.items.push({
titleMain: self.myArrays[Math.floor(Math.random() * self.myArrays.length)],
picUrl: self.myArrays[Math.floor(Math.random() * self.myArrays.length)],
titleSub: self.myArrays[Math.floor(Math.random() * self.myArrays.length)],
itemHref: self.myArrays[Math.floor(Math.random() * self.myArrays.length)]
});
self.$setState({
items: self.items,
});
done();
}, 1000);
}
}
};
Thanks in advance…