grunt-doctrine
Version:
Grunt plugin to convert doctrine xml annotations into backbone models and collections. Useful in conjunction with doctrine apigility. Includes option to scaffold an entire BBB application
70 lines (48 loc) • 2.08 kB
HTML
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
<title>Content Editable Example</title>
<!-- include source files here... -->
<script type="text/javascript" src="../lib/underscore.js"></script>
<script type="text/javascript" src="../lib/jquery.js"></script>
<script type="text/javascript" src="../lib/backbone.js"></script>
<script type="text/javascript" src="../Backbone.ModelBinder.js"></script>
<script>
$().ready(function () {
model = new Backbone.Model();
model.set({firstParagraph: 'This is the first paragraph'});
model.bind('change', function () {
$('#modelData').html(JSON.stringify(model.toJSON()));
});
model.trigger('change'); // just to show the #modelData values initially, not needed for the ModelBinder
ViewClass = Backbone.View.extend({
_modelBinder: undefined,
initialize:function () {
this._modelBinder = new Backbone.ModelBinder();
},
close: function(){
this._modelBinder.unbind();
},
render:function () {
var html = '\
\
<div name="firstParagraph" contenteditable style="height: 100px; width: 300px; border:solid"></DIV> \
';
this.$el.html(html);
this._modelBinder.bind(model, this.el, {firstParagraph: {selector: '[name=firstParagraph]', elAttribute: 'html'}});
return this;
}
});
view = new ViewClass();
$('#viewContent').append(view.render().$el);
});
</script>
</head>
<body>
<br>
Model data: <div id="modelData"></div>
<hr><br>
<div id="viewContent"></div>
</body>
</html>