CanJS jQuery Template
Includes jQuery, CanJS and all of its plugins. Use it as a starting point when you want to demo something.
by cherif_b
HTML
<script src="http://canjs.us/release/latest/can.jquery.js"></script>
<script src="http://canjs.us/release/latest/can.construct.proxy.js"></script>
<script src="http://canjs.us/release/latest/can.control.plugin.js"></script>
<script src="http://canjs.us/release/latest/can.view.modifiers.js"></script>
<script src="http://canjs.us/release/latest/can.construct.super.js"></script>
<script src="http://canjs.us/release/latest/can.object.js"></script>
<script src="http://canjs.us/release/latest/can.ejs.js"></script>
<script src="http://canjs.us/release/latest/can.map.attributes.js"></script>
<script src="http://canjs.us/release/latest/can.map.backup.js"></script>
<script src="http://canjs.us/release/latest/can.map.delegate.js"></script>
<script src="http://canjs.us/release/latest/can.map.setter.js"></script>
<script src="http://canjs.us/release/latest/can.map.validations.js"></script>
<script src="http://canjs.com/release/latest/can.fixture.js"></script>
<script src="http://canjs.com/release/latest/can.map.define.js"></script>
<script src="http://canjs.com/release/latest/can.stache.js"></script>
<div class="header">
<h1>CanJS jQuery Template</h1>
<p>This template includes jQuery, CanJS and all of its plugins. Use it as a starting point when you are submitting a question to <a href="https://twitter.com/#!/canjs" target="_blank">Twitter</a>, the <a href="https://forum.javascriptmvc.com/#Forum/canjs" target="_blank">forums</a> or IRC.</p>
<p>Don't want jQuery? Here are links to templates for other libraries:<br>
<a href="http://jsfiddle.net/donejs/9x96n/">Dojo</a> |
<a href="http://jsfiddle.net/donejs/w6m73/">YUI</a> |
<a href="http://jsfiddle.net/donejs/mnNJX/">Mootools</a> |
<a href="http://jsfiddle.net/donejs/7Yaxk/">Zepto</a>
</p>
</div>
<!-- YOUR CODE HERE -->
<div id="dummy"></div>
<!-- PUT ANY TEMPLATES YOU NEED HERE -->
<script id="dummyMustache" type="text/mustache">
<a...
CSS
.header {
background: #E1E3E1;
padding: 10px 0;
border-bottom: 1px solid #B5B6B5;
margin-bottom: 15px;
}
h1 {
font-size: 24px;
font-weight: bold;
}
p {
margin: 10px 0;
}
JavaScript
can.Map.extend('AppState',{
define:{
page:{
set:function(val){
return val ? val : 'home';
},
view:{
set:function(val){
return val ? val : 'index';
}
}
}
}
});
can.Component.extend({
tag:'x-app',
template:'Here',
init:function(){
can.route.map(this.scope);
can.route(':app',{
app:'home',
view:'index'
});
can.route.ready();
},
scope:function(){
return new AppState();
},
events:{
init:function(el){
el.addClass('container');
el.append(can.stache('<x-navigator class="pop"/>'));
},
inserted:function(el,ev){
console.log('Inserted');
var d=JSON.stringify(can.route.attr());
el.find('x-navigator').append(d);
}
}
});
$('body').append(can.stache('<x-app/>')());