son et lumiere
Member
I'm having a bit of a problem. I can't get any javascript to run in a template.
For example:
At first I tried this, just to see what it would spit out, but it didn't work.
So then I tried to simplify it:
...and it still didn't work!
This is on a custom template which I'm calling inside message_user_info. I even tried placing the js in page_container's head and body but nothing works. I tried wrapping it in a function, no change.
What am I doing wrong?
For example:
Code:
<div id="jsDataDump"
LegacyRep = "{$visitor.customFields.LegacyRep.no}"
DisplayRep = "{$user.customFields.RepDisplay.no}"
UserID = "{$user.user_id}"
Username = "{$user.username}"
TotalRep = "{$user.xf_bdreputation_given}"
><xen:comment>This div is converting xenforo variables into javascript variables</xen:comment>
</div>
<p id="DataSpew">test</p>
<script>
var LegacyRep = $(#jsDataDump).attr('LegacyRep');
var DisplayRep = $(#jsDataDump).attr('DisplayRep');
var UserID = $(#jsDataDump).attr('UserID');
var Username = $(#jsDataDump).attr('Username');
var TotalRep = $(#jsDataDump).attr('TotalRep');
document.getElementById("DataSpew").innerHTML = TotalRep;
</script>
At first I tried this, just to see what it would spit out, but it didn't work.
So then I tried to simplify it:
Code:
<p id="test"></p>
<script>
document.getElementById("test").innerHTML = "Anything?";
</script>
...and it still didn't work!
This is on a custom template which I'm calling inside message_user_info. I even tried placing the js in page_container's head and body but nothing works. I tried wrapping it in a function, no change.
What am I doing wrong?