Reputation: 1782
In my .xsl file I have this code:
importantMsg = null;
<script type="text/javascript">
$.getScript("std/lamFile.js").done(function(script, successOrFail, exept) {
importantMsg = getMessage();
});
</script>
isoNS.PanelQ<xsl:value-of select="@CHECKID"/>Pensl = new Ext.Panel
({<xsl:if test="@CHECKID=9051">
items: [
{
xtype: 'label',
id: 'attentionLabel',
width: 200,
style: 'margin: 100px 0px 0px 24%;',
text: importantMsg <---------------- variable goes Here
}
]
</xsl:if>
});
I load a js file, and then call the getMessage
method, which returns a string. This string is the one I call importantMsg, as you can see in the code. Now I want to use this string in the extjs code, where I have the label xtype. But the importantMsg is not set here, it is just undefined. So I guess I should get it using xsl? How can I do this?
The weird thing is that, if I write an alert("");
before the Ext.Panel is created, then the importantMsg will be inserted.
Any help is greatly appreciated
Upvotes: 0
Views: 55
Reputation: 70618
I don't think this is anything to do with XSLT. The XSLT is generating javascript text, but by the time the javascript runs, the XSLT is long since forgotten about. There is no interaction between them.
I would guess the issue is that the jquery function $.getScript
function is asynchronous, and currently your code to see the new Ext.Panel
is running before $.getScript
completes. (With the alert in, this does allow $.getScript
to complete, and thus it appears to work).
The solution is probably re-order the statements, so the setting of the text
property is done by the callback function of $.getScript
.
Something like this...
importantMsg = null;
isoNS.PanelQ<xsl:value-of select="@CHECKID"/>Pensl = new Ext.Panel
({<xsl:if test="@CHECKID=9051">
items: [
{
xtype: 'label',
id: 'attentionLabel',
width: 200,
style: 'margin: 100px 0px 0px 24%;',
text: importantMsg <---------------- variable goes Here
}
]
</xsl:if>
});
<script type="text/javascript">
$.getScript("std/lamFile.js").done(function(script, successOrFail, exept) {
importantMsg = getMessage();
<xsl:if test="@CHECKID=9051">
isoNS.PanelQ<xsl:value-of select="@CHECKID"/>Pensl.items[0].text = importantMsg;
</xsl:if>
});
</script>
Upvotes: 1