This is a bug.
When adding the pull-to-refresh programmatically, neither the arrow down nor the spinner shows.
Actually, you can reproduce the same by just pasting in the pull-to-refresh-html in developer modus in chrome instead of doing it by code. The sample below doesn't format properly, but I hope you understand.
html:
<body>
<!-- Status bar overlay for full screen mode (PhoneGap) -->
<div class="statusbar-overlay"></div>
<div class="panel-overlay"></div>
<!-- Views -->
<div class="views">
<div class="view view-main">
<div class="pages">
<div id='home' data-page="home" class="page navbar-fixed toolbar-fixed">
</div>
</div>
</div>
</div>
<script type="text/javascript" src="main.js"></script>
</body>
js:
var myApp = new Framework7();
var mainView = myApp.addView('.view-main', {
dynamicNavbar: true
});
var win = require('window');
win.$$ = Dom7;
win.app = myApp;
var region = document.getElementById('home');
var cont = '<div class="navbar">
<div class="navbar-inner">
<div class="left"></div>
<div class="center">Climbing gyms</div>
<div class="right"></div>
</div>
</div>
<div data-name="pullToRefreshGyms" id="pullToRefreshGyms" class="page-content pull-to-refresh-content" data-ptr-distance="55">
<div class="pull-to-refresh-layer">
<div class="preloader"></div>
<div class="pull-to-refresh-arrow"></div>
</div>
</div>';
win.$$('#home').html(cont);
The html I am inserting dynamically in the home element is this:
<div class="navbar">
<div class="navbar-inner">
<div class="left"></div>
<div class="center">Climbing gyms</div>
<div class="right"></div>
</div>
</div>
<div data-name="pullToRefreshGyms" id="pullToRefreshGyms" class="page-content pull-to-refresh-content" data-ptr-distance="55">
<div class="pull-to-refresh-layer">
<div class="preloader"></div>
<div class="pull-to-refresh-arrow"></div>
</div>
</div>
Maybe you can format your code(using ``instead of), and others can clearly see the question
<div className="views">
<div className="view view-main">
<div className="page">
<div className="page-content pull-to-refresh-content" data-ptr-distance="85">
<div className="pull-to-refresh-layer">
<div className="preloader"></div>
<div className="pull-to-refresh-arrow"></div>
</div>
<div className="list-block">
<ul>
<li className="item-content">
<div className="item-media"><img src="http://hhhhold.com/88/d/jpg?1" width="44" /></div>
<div className="item-inner">
<div className="item-title-row">
<div className="item-title">Yellow Submarine</div>
</div>
<div className="item-subtitle">Beatles</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
The html structure is important in F7!!!! If there was any wrong with the code ,plz checked the structure of the html from the official demo
This html structure is work, and we can put the list content into ul
Finally, dont forget to initialize the js and add listener into the dom
let $$ = Dom7;
let myApp = new Framework7();
let ptrContent = $$('.pull-to-refresh-content');
// Add 'refresh' listener on it
ptrContent.on('refresh', function (e) {
// Emulate 2s loading
setTimeout(function () {
myApp.pullToRefreshDone(); // After we refreshed page content, we need to reset pull to refresh component to let user pull it again:
}, 2000);
});
I have formatted it properly now.
I left out the listening on the refresh event in this sample for convenience.
you can't create it dynamically! the various listeners wont get added!
Well, that is major problem. Shouldn't a framework like this support adding html at runtime ?
Is there any workarounds for this ?
it's actually quite tricky to do. maybe explain why you want to do it?
I have a recursive list of items. Inside an item there could be more items. I do not know in advance how deep it will be. I depends on the data received from the server.
Just checked the docs and i suggest you try
myApp.initPullToRefresh("#pullToRefreshGyms");
Success !
Thank you.
I had the same issue. The official doc example mentions the sample code as
// Add 'refresh' listener on it
ptrContent.on('ptr:refresh', function (e) {
It should be
// Add 'refresh' listener on it
ptrContent.on('refresh', function (e) {
@vishnoor Is right, it should be 'refresh' instead of 'ptr:refresh'. The docs should be changed to reflect this. Thanks vishnoor.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Success !
Thank you.