Does [evalkeywords] attribute print AFTER [client javacript] onclick


(Dalano) #1

Hello Squiz support,

I am trying to print squiz asset AFTER simple frontend javascript onclick. Please see the following sample code:

<div class="row row-tight">
    <div>
        <p><a href="#" data-reveal-id="blah1" class="cta-secondary" onclick="clickedElement(this)">Scopus form test</a>
        </p>
        <div id="blah1" class="reveal-modal" data-reveal="" aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
             <!--@@DYNAMIC@@-->
            
        </div>
    </div>
    <div>
        <p><a href="#" data-reveal-id="blah2" class="cta-secondary" onclick="clickedElement(this)">Funding Institutional form</a>
        </p>
        <div id="blah2" class="reveal-modal" data-reveal="" aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
            <!--@@DYNAMIC@@-->
			
        </div>
    </div>
</div>
<script evalkeywords="post">
function clickedElement(elemId) {
    var lightboxId = elemId.getAttribute('data-reveal-id');
    var html;
    if ( lightboxId == 'blah1') { // clear the content of the other lightbox
        document.getElementById('blah2').innerHTML = '';
        html = print('%globals_asset_contents_raw:7777777'); // blah1 i.e., #7777777 is printed AFTER js event click
    } 
	else {
        document.getElementById('blah1').innerHTML = '';
        html = print('%globals_asset_contents_raw:8888888'); // blah2 i.e., #8888888 is printed AFTER js event click
    }
    return elemId.getElementById(lightboxId).innerHTML = html;
}
</script>

End result is that globals_ are printed despite the attribute inlined into script tags evalkeywords=“post”

Am i missing something here, would please help.

Thanks in advance!


(Dalano) #2

After a little research found helpful feedback given by @Douglas :pray:

Server to client (normal) javascript comms should be doable by storing values in the page markup that are then later available to client side JS. Some level of comms between them might be possible to achieve that way and through the client side then calling on assets containing server side code, but I’ve not played in that space - we tend to have a firm divide between server generated content and then client code to augment whatever the server code has put in place.

Based on that i am now getting my hands to store a dynamic value from standard page asset. Please someone to flag if i’m on wrong direction. Thanks guys.


(Bart Banda) #3

Yep, that sounds like a good approach.