Use like this syntax
dmx.app.data.serverconnect.data.abc
Use like this syntax
dmx.app.data.serverconnect.data.abc
Thanks for replying @s.alpaslan
If my value is returned with
{{serverconnectheader.data.querysigheader[0].sig}}
what I should the following be?
var sig = dmx.?
var sig={{serverconnectheader.data.querysigheader[0].sig}}
to bind a value to the hidden field go to dynamic attributes->value and select the server connect returned value, no need for variables
The code is probably called to early, the sig data isn’t loaded yet on document ready.
Have a function on the page to set the signature and call it on the done event of your json datasource.
<dmx-json-datasource id="jsonDS1" is="dmx-serverconnect" url="sig.json" ondone="regenerateSig()"></dmx-json-datasource>
<script>
function regenerateSig() {
$('.sigPad').signaturePad({displayOnly:true}).regenerate(dmx.parse('jsonDS1.data'));
}
</script>
Sorry, I’m slightly confused
The sig value is already stored MSSQL database, a server action and app connect serverconnect returns the record with the sig value. (Classic ASP Server Model)
Here is the documentation I’m following to regenerate the JSON formatted value.
https://github.com/thread-pond/signature-pad/blob/gh-pages/documentation.md
If I add
var sig = [{lx:20,ly:34,mx:20,my:34},{lx:21,ly:33,mx:20,my:34},…];
The value in my database it works
I just cant seem to dynamically set var sig to the {{serverconnectheader.data.querysigheader[0].sig}} value
maybe the issue have something to do with app connect loading the value after your script execute
have you tried this?
var sig={{serverconnectheader.data.querysigheader[0].sig}}
Hi @Hyperbytes
Yes I have, should that work within the script tag?
Error: Uncaught SyntaxError: Unexpected token
dmx.app.data.querysigheader[0].sig
Try please
Sorry, didn’t realise you were working within a script tag.
an alternative could be to assign the value to a session variable within server connect as shown in the start of this thread then set it via php I.e.
var sig = <?php echo $_SESSION..........?>
You can use dmx.parse
to parse expressions inside javascript, so adding dmx.parse('serverconnectheader.data.querysigheader[0].sig')
would give you the signature json. But you have to wait until the data is loaded before accessing it, otherwise you just get an undefined
.
The code I gave before also works with server connect, just hook in the done event from server connect and execute the function to generate the signature.
<dmx-serverconnect id="serverconnectheader" url="<<action_url>>" ondone="regenerateSig()"></dmx-serverconnect>
<script>
function regenerateSig() {
$('.sigPad').signaturePad({displayOnly:true}).regenerate(dmx.parse('serverconnectheader.data.querysigheader[0].sig'));
}
</script>
Perfect - Fabulous!
Thanks @patrick
I know this thread is old but @patrick’s suggestions for injecting into javascript code worked like a champ and saved me a ton of time parsing Link Headers from an API I’m working with.
Thank you!!!