Intercepting an HTML asset's [DONE] button let's you create any kind of cool tricks with HTML assets. You can have a popup message that says 'Goodbye' to the user, or any kind of reminder or message that pops up when when the user clicks the 'Done' button. You can also use it to jump to another asset, rather than just closing the asset. You can even check if a field of Form has been set to a certain value and trigger a different logic than closing the asset - e.g. fill out another form. 


To implement this, add the following code to the nexti_metadata.json file

<key>property_html_brochureControlsClose</key><string>YES</string>

and intercept the 'close' function by running a script that uses window.onbeforeunload() 

<script type="text/javascript">
        window.onbeforeunload = function() {
//Your code here
}
window.document.location = 'ni-action:close';
</script> 

   

When property_html_brochureControlsClose is set to YES and an asset's [DONE] button is tapped, the callback window.onbeforeunload() is initiated allowing the asset to handle clean-up or similar before it is closed, followed by ni-action:close URI, which then closes the asset.


This allows the asset to do async network stuff etc before closing.


NOTE: if the property_html_brochureControlsClose key is set to NO then both, the DONE and ni-action:close will do exactly the same.

 

Important: If theproperty_html_brochureControlsClose key is set to YES in nexti_metadata.plist or nexti_metadata.json file the callback MUST exist in the HTML asset, otherwise the asset won't be able to be closed.