When for example tracking conversions on your site with Google analytics you may be required to execute a small google provided script on certain actions.
If your are in Blazor or AngularJS rendering we know that you have a browser in the user end.
If you assign an existing js-function name (that you provide with a js file and include in component or global scripts) in this fomat:
FunctionName(argument)
The client (both blazor and angularJS) will detect and call this pre existing function by assigning a special string variable named vClientScriptExecute :
vClientScriptExecute:='MDrivenClientScriptExecute("Some string arg")' -- argument double quotate
We will try and match with: thescriptref.match(/^(\w+)\s*\(\s*"([^"]*)"\s*\)$/); - so you must include a param in double quotes
Once the vClientScriptExecute has a new value - the client will try and call it.
Do you need more arguments you need to encode them in the one argument available.
How to test:
- In EXT_Scripts/AppWideAngularScriptIncludes.htm put this line: <script src='EXT_Scripts/MyThings.js'></script>
- Create new file in EXT_Scripts/MyThings.js
- In MyThings.js add: function ThisIsMyFunction(param1){window.alert('This is my function alert('+param1+')')}
- In viewModel add Action with expression: vClientScriptExecute:='ThisIsMyFunction("hello man")'
Expected outcome: When you click the action - alert is showing like this: