-
28 Sep 2012 1:37 AM #1
Unanswered: Array Length in XTemplate
Unanswered: Array Length in XTemplate
Hi,
I'm trying to display something if an array is empty in an Xtemplate.
My code:
Code:'<tr><td class="pendingDocsSignedTableTitle">Signed By:</td></tr>' + '<tpl if="signedUsers.length == 0">', '<tr><td class="pendingDocsSignedTableUser">No users signed</td></tr>', '</tpl>', '<tpl for="signedusers">', '<tpl if="xcount > 0">', '<tr><td class="pendingDocsSignedTableUser">{sn} - {[this.formatFDate(values.d)]} </td></tr>', '</tpl>', '</tpl>',
BBUT the
part does not seem to work. Anybody have an idea on how to do this ?Code:'<tpl if="signedUsers.length == 0">', '<tr><td class="pendingDocsSignedTableUser">No users signed</td></tr>', '</tpl>',
-
28 Sep 2012 3:20 AM #2
This because signedUsers key undefined, check for undefined to:
demo: http://jsfiddle.net/rJFYS/1/Code:'<tpl if="values.signedUsers == undefined || values.signedUsers.length == 0">'
-
28 Sep 2012 3:24 AM #3
Thanks for the response... but i just found out why it wouldn't work... and i feel like an .
i used signedUsers where signedusers is the right one.
Ty javascript for not throwing decent errors on capitalization
Sorry for your time
-
28 Sep 2012 3:56 AM #4
No problem)
//wbr


Reply With Quote