Ciao ragazzi sto provando a usare JQuery Mobile e JQuery template assieme...
ho trovato questo codice molto semplice che pero' da un risultato diverso da quello che mi aspetto:
codice:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js">
</script>
<script src="//code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js">
</script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js">
</script>
</head>
<body>
<ul id="movieList" data-role="listview" >
[/list]
<script>
var movies = [ {Name: "The Red Violin", ReleaseYear: "1998"},
{Name: "Eyes Wide Shut", ReleaseYear: "1999" },
{Name: "The Inheritance", ReleaseYear: "1976" }];
var markup = "[*]${Name} (${ReleaseYear})";
/* Compile the markup as a named template */
$.template("movieTemplate", markup);
/* Render the template with the movies data and insert
the rendered HTML under the "movieList" element */
$.tmpl("movieTemplate", movies).appendTo("#movieList");
alert("fatto")
</script>
</body>
</html>
Viene invocato 2 volte lo script e non capisco il motivo, la lista avrà 6 righe invece che 3 perchè vengono aggiunte 2 volte! Infatti anche l'alert che ho messo è visualizzato 2 volte!
Qualcuno potrebbe illuminarmi sul perchè viene invocato 2 volte?