Hi all
I’m trying to build a repeater function using F7 v7. Can anyone give some ideas how to do so?
Here what I’ve already tried:
Using the $f7.request()
I’m calling a “placeholder file”, this file is pure HTML. After I get the result os this request, I tried to append this HTML inside of the page using the $f7.$('selector').append()
.
The idea it self almost works, but when the HTML is appended into selector, seams that the new HTML is missing classes and ids.
Here my JS inside the page:
<script>
export default (props, { $update, $f7, $el, $theme, $on }) => {
let section = 1;
function add_new( section ){
$f7.request({
method: 'get',
url: '../pages/inspection/placeholders/2-filter.f7',
}).then((res) => {
let html = {
section: section,
content: $f7.$( res.data.replaceAll('${section}', section) )
}
$f7.$('form').append( html.content );
});
$update();
}
$on('pageInit', (event, page) => {
console.log( $f7 );
add_new( section );
$f7.$('#add_filter').on('click', function(){
section++;
add_new( section );
});
});
return $render;
}
</script>
And in my page application I got this result:
Look how the HTML structure after append looks like:
And how should be (this is the “placeholder template file”)
Sandbox demo (updated)
Does anyone have any ideal how to build this repeater function or what’s happening with these missing parts?
Thank you