What's supposed to happen: Every time I click an item in a list (single selection), information in that object is displayed on a separate div.
The problem: I can't get the information to display on the separate div.
Table containing the list and the preview area is supposed to display:
<table id="preview" style="width: 100%;" class="border">
<tr>
<td style="width: 25%;">
<!-- List here -->
</td>
<td style="width: 75%;">
<div id="template_preview" style="overflow:auto">
</div>
</td>
</tr>
</table>
On load, this will be called:
<script type="text/javascript" language="javascript">
$(document).ready(function(){
changePreview();
});
</script>
The changePreview()
function:
function changePreview()
{
var selectedValueFromListId = $('#listId').val();
$('#template_preview').html('<c:forEach var="some_var" items="${model.someList}">');
$('#template_preview').append('<input type="hidden" id="someTemplateId" value="${some_var.someListId}" />');
var someTemplateId = $('#someTemplateId').val();
if (selectedValueFromListId == someTemplateId)
{
$('#template_preview').append('test');
$('#template_preview').append('<c:if test="${some_var.objectOne.objectTwo.objectTwoId == valueOfSomething}">');
$('#template_preview').append('some text here - <c:out value="${some_var.label}" />');
$('#template_preview').append('</c:if>');
}
$('#template_preview').append('</c:forEach>');
}
I haven't tested out jQuery's .html()
or .append()
functions before so I'm not sure if I'm using them right or if what I'm trying to do is possible.
I hope I've explained my problem in enough detail. I've tried researching it in search sites but so far I haven't found a solution.
Thanks in advance.