Ho difficoltà a determinare se i dati passati nel modello jQuery esistono e sono falsi senza ottenere errori. Questo è quello che sto usando per testarecome sapere se una proprietà esiste ed è falsa
<html>
<head>
<title>jQuery Templates {{if}} logic</title>
</head>
<body>
<p id="results"></p>
<p>How do you test if the Value exists and is false?</p>
<script id="testTemplate" type="text/html">
Test ${Test}:
{{if Value}}
Value exists and is true
{{else}}
Value doesn't exist or is false
{{/if}}
<br/>
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.tmpl.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#testTemplate").tmpl({Test:1}).appendTo("#results");
$("#testTemplate").tmpl({Test:2, Value:true}).appendTo("#results");
$("#testTemplate").tmpl({Test:3, Value:false}).appendTo("#results");
});
</script>
</body></html>
Qualcuno sa come farlo?
non sembra carino ma funziona, grazie! –