Widget:Laad meer berichten: verschil tussen versies
Uit Dorpsbelang Den Hout
(4 tussenliggende versies door dezelfde gebruiker niet weergegeven) | |||
Regel 1: | Regel 1: | ||
+ | <button class="btn" onclick="loadMoreBerichten(<!--{$offset}-->)" >Laad meer</button> | ||
<script>var offset=0; | <script>var offset=0; | ||
function loadMoreBerichten(set){ | function loadMoreBerichten(set){ | ||
− | + | ||
Regel 17: | Regel 18: | ||
</div> | </div> | ||
</div> | </div> | ||
− | |}}` | + | |}}`; |
− | + | offset += set; | |
var params = { | var params = { | ||
action: 'parse', | action: 'parse', | ||
Regel 29: | Regel 30: | ||
console.log(data.parse.text['*']) | console.log(data.parse.text['*']) | ||
var newrow = document.createElement('div'); | var newrow = document.createElement('div'); | ||
− | + | // newrow.classList.add('row') | |
− | + | // document.body.appendChild(newrow); | |
+ | |||
newrow.innerHTML = data.parse.text['*']; | newrow.innerHTML = data.parse.text['*']; | ||
+ | newrow.querySelectorAll('.col-md-6').forEach(function(el){ | ||
+ | |||
+ | document.querySelector('.fa-plus').closest('.row').insertBefore(el, document.querySelector('.fa-plus').closest('.col-md-6')) | ||
+ | }) | ||
+ | |||
}) | }) |
Huidige versie van 20 aug 2020 om 07:03
<button class="btn" onclick="loadMoreBerichten()" >Laad meer</button> <script>var offset=0; function loadMoreBerichten(set){
var wikitext = `... meer resultaten`;
offset += set;
var params = {
action: 'parse',
text: wikitext,
contentmodel: 'wikitext',
format: 'json'
},
api = new mw.Api();
api.post( params ).done( function ( data ) {
console.log(data.parse.text['*'])
var newrow = document.createElement('div');
// newrow.classList.add('row')
// document.body.appendChild(newrow);
newrow.innerHTML = data.parse.text['*'];
newrow.querySelectorAll('.col-md-6').forEach(function(el){
document.querySelector('.fa-plus').closest('.row').insertBefore(el, document.querySelector('.fa-plus').closest('.col-md-6'))
})
})
} </script>