There are similar question titles on this site and I have read all of their solutions, but the problem was always related to Turbolinks or something additional. In this case, I'm using javascript/jQuery only, so those solutions are irrelevant.
I have written a simple script which finds the tallest container and then adjusts the rest of the containers in the block to be the same height as the tallest one. I applied this script to the Squarespace summary block so that all of the summary items in the same block are the same height.
I then added a conditional statement that would cause this functionality to be executed only at screen width of above 810px.
The outcome is that this script works exactly as it should but only when I get to the page directly or refresh the page. It does NOT work if I navigate to the page from another page.
$(function() {
if($(window).width() > 810){
var maxheight=-1;
$('#block-yui_3_17_2_25_1494432854570_9795 .summary-excerpt').each(function() {
if(maxheight < $(this).height())
{
maxheight = $(this).height();
}
});
$('#block-yui_3_17_2_25_1494432854570_9795 .summary-excerpt').each(function() {
$(this).height(maxheight);
});
}
});
Would really appreciate any ideas as I have looked into every question that was similar to mine and none of the solutions worked for me.
NOTE: I do not get an error. I placed an alert() right before the if statement and that confirmed that the function does not run when you navigate to the page from another page. I do, however, get an alert when I refresh the page, as expected.