I have a json array with the key ‘BASIS-TYPE’. If I use this value in the markup:
<html>
<head>
<script src="/js/jquery-1.7.min.js"></script>
<script src="/js/jquery-plugins/jquery.tmpl.min.js"></script>
<script>
$(document).ready(function(){
var jsonarray = {"_id":"15", "BASIS-TYPE":"80"}
var markup = "<tr><td>${_id}</td><td>${BASIS-TYPE}</td></tr>";
$.template( "tableTemplate", markup);
$("#templtable").replaceWith('<table id="templtable">'+headers+'</table>');
$.tmpl( "tableTemplate", jsonarray ).appendTo("#templtable");
}
</script>
</head>
<body>
Tabel:</br>
<table id="templtable"></table>
</body>
</html>
it will look for ‘BASIS‘ and not ‘BASIS-TYPE‘, throwing the error:
Uncaught ReferenceError: BASIS is not defined
Replacing BASIS-TYPE will show the required results.
Is there any solution to this?
This change to the template will solve your problem: