Sha256: e1e98d88a72126d5e2e86e0a1e2e5af0a2420bc0753534b26e02f59c1c749434

Contents?: true

Size: 1.94 KB

Versions: 15

Compression:

Stored size: 1.94 KB

Contents

<!DOCTYPE html>
<html>
<head>
	<link href="resources/presentation.css" rel="stylesheet" type="text/css" />
	<link href="resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
	<script src="resources/syntaxhighlighter.min.js" type="text/javascript"></script>

	<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
	<script src="../../jsrender.js" type="text/javascript"></script>
	<script src="../../jquery.observable.js" type="text/javascript"></script>
	<script src="../../jquery.views.js" type="text/javascript"></script>
</head>
<body>
<a href="07_observable.html">Prev</a> <a href="index.html">Home</a> <a href="07_observable3.html">Next</a><br />

<h3>9 Observable collection changes: JsViews</h3>

<p><button id="insertPerson">Insert person</button></p>

<!--====== Container ======-->
<table><tbody id="details"></tbody></table>

<!--====== Template ======-->
<script id="personTmpl" type="text/x-jsrender">
	<tr>
		<td data-link="firstName" />
		<td>
			<input data-link="firstName" />
		</td>
	</tr>
</script>

<!--====== Script ======-->
<script type="text/javascript">

var people = [
	{
		firstName: "Jeff"
	},
	{
		firstName: "Rebecca"
	}
];

// Compile template
$.templates( "personTmpl", "#personTmpl" );

// Data-link details container to people, using the personTmpl template
$.link.personTmpl( "#details", people );

// Observable array change
$( "#insertPerson" ).click( function() {
	$.observable( people ).insert( 0, { firstName: "NewPerson" });
});

</script>

<!--================ End of Demo Section ================-->

<h4>HTML:</h4>
<pre class="brush: xml;">
...
    &lt;td data-link="firstName" />
    &lt;td>
        &lt;input data-link="firstName" />
    &lt;/td>

</pre>

<h4>Script:</h4>
<pre class="brush: js;">
$.link.personTmpl( "#details", people );

// Observable array change
$( "#insertPerson" ).click( function() {
    $.observable( people ).insert( 0, { firstName: "NewPerson" });
});
</pre>
</body>
</html>

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
kit_cms-2.3.22 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.20 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.19 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.18 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.17 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.16 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.15 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.14 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.13 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.11 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.10 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.9 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.8 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.7 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html
kit_cms-2.3.6 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/07_observable2.html