I use the jTemplates plugin to load data on my tables. Because there are some properties I do not display yet I want available for later use, I save them in hidden fields and then grab them by their CSS's class name and jQuery's siblings
method.
Is this a correct way of doing such operation, or would this be considered terrible code?
<script type="text/javascript">
$(function() {
$("#edit").click(function(e) {
e.preventDefault();
var $this = $(this);
var date = {
Id: $this.siblings(".tid").val(),
StartDate: $this.siblings(".tdate1").val(),
EndDate: $this.siblings(".tdate2").val(),
ClientId: $this.siblings(".tclient").val(),
UserId: $this.siblings(".tuser").val()
};
processDate(date);
});
});
</script>
<textarea id="template" class="ui-helper-hidden">
<table id="dates">
<thead>
<tr>
<th>Id</th>
<th>Start Date</th>
<th>End Date</th>
<th>Client</th>
<th></th>
</tr>
</thead>
<tbody>
{#foreach $T as record}
<tr>
<td>{ $T.record.Id }</td>
<td>{ formatDate($T.record.StartDate) }</td>
<td>{ formatDate($T.record.EndDate) }</td>
<td>{ $T.record.Client.Name }</td>
<td>
<button id="edit">Edit</button>
<input type="hidden" class="tid" value='{ $T.record.Id }' />
<input type="hidden" class="tdate1" value='{ $T.record.StartDate }' />
<input type="hidden" class="tdate2" value='{ $T.record.EndDate }' />
<input type="hidden" class="tclient" value='{ $T.record.Client.Id }' />
<input type="hidden" class="tuser" value='{ $T.record.User.Id }' />
</td>
</tr>
{#/for}
</tbody>
</table>
</textarea>
Suggestions will be gladly accepted. :)