PDA

View Full Version : need to pass parameters from the XTemplate to a javascript function , please help me



raikoti sravan kumar
25 Jun 2012, 6:34 AM
'<tr>',
'<tpl for="."><td width="10%" style="padding:5px 5px 5px 5px"><div >{fullVin}</td> </tpl>'
'</tr>',

'<tr>',
'<tpl for="."><td width="10%" style="padding:5px 5px 5px 5px"><div >{userBAC}</td> </tpl>'
'</tr>',

In the above piece of code, the 2 values which are part of template {fullVin}, {userBAC} need to be passed as arguments to a javascript funtion called from the same Xtemplate code, below is the piece of code where i am calling printInvoice() fuction onclick of hyperlink and passing the above 2 values and the function is not getting called. Please help


'<tpl for="."><td width="10%" style="padding:5px"><div>
<tpl if="xindex != 1"><a href="#" onclick="printInvoice({fullVin},{userBAC})"></tpl>{printInvoice}<tpl if="xindex != 1"></a></tpl></td> </tpl>'+
'</tr>','</tpl>',

25 Jun 2012, 6:37 AM
1) Stop using onClick! it's old and really not the best way to register click events.

2) try {[ myNamespace.myFn(values.someKey, values.someOtherKey, values.anotherKey) ]}