Hello,
I have no idea if personal coding problems (= problems that others won't have) are allowed here (if it's not the case and that I must rather ask on stackoverflow or something, don't hesitate to tell me and to delete ths post).
+ BEWARE, the newbie level goes through the roof in this post, I basically talk about a language (javascript) I understand nothing about...
The issue
I try to set a tag's order into the tag cloud, but being on freeflarum for now, I can't touch the html, and must replace the current tag-cloud with a manually created one (in which I sorted the tags myself) through javascript.
My goal is to constantly replace the original tagcloud (.TagsPage-content .TagCloud
) with a div I created in the footer (.TagCloud-order
) which contains the tags in the right order.
And it works, with this code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> </script>
<script>
$(document).ready(function() {
$('.TagsPage-content .TagCloud').replaceWith($('.TagCloud-order').html());
});
</script>
... but it works only on the first page load.
When I arrive on the main page (which is the tags one), the replacement has indeed been made (the page shows the .TagCloud-order
div instead of the original one). But if I click anywhere ("all discussion" for instance), then come back to the tag page (by clicking on "Tags"), the replacement is not there anymore (tags are in their usual non-sorted order, it's the original div).
You can see it yourself on the forum: https://forum.cinestudia.fr/
So my question here is: considering the way Flarum is working when you navigate in it (changing the url, but not re-loading the whole page, if I understand well), what kind of javascript must I use for the order to be constant? As $(document).ready
doesn't seem to work (logically) beyond the first page load...