This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form> | |
<input class="name" type="text"/> | |
<input class="email" type="text"/> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var View = Marionette.ItemView.extend({ | |
events: { | |
"input input.name": "onNameChange", | |
"input input.email": "onEmailChange" | |
}, | |
onNameChange: function(e) { | |
this.model.set('name', $(e.currentTarget).val()); | |
}, | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var View = Marionette.ItemView.extend({ | |
// A function that takes a hash of the serialized | |
// Model and returns the HTML for display | |
template: templateFunc, | |
ui: { | |
// A hash of id to jquery selectors | |
nameInput: "input.name" | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="text" data-bind="value: value, toggle: editorOpen"/> | |
<i class="icon icon-pencil" data-bind="toggle: editVisible"> | |
<i class="icon icon-trash" data-bind="toggle: deleteVisible"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ViewModel = Backbone.Epoxy.Model.extend({ | |
defaults: { | |
editorOpen: false, | |
editable: true, | |
required: false | |
}, | |
computeds: { | |
deleteVisible: function() { | |
return !this.getBinding("editorOpen") && | |
this.getBinding("editable") && |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Epoxy.Model.extend({ | |
computeds: { | |
isRunning: function() { | |
return this.getBinding("status") === "running"; | |
}, | |
isCompleted: function() { | |
return this.getBinding("status") === "completed"; | |
} | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="link"> | |
<a href="<%- linkUrl %>" title="<%- linkText %>"><%- linkText %></a> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var View = Marionette.ItemView.extend({ | |
ui: { | |
link: ".link a" | |
}, | |
onRender: function() { | |
// We need to update the view when the text changes | |
this.listenTo(this.model, "change:linkText", function() { | |
this.ui.link.text(this.model.get("linkText")); | |
this.ui.link.attr('title', this.model.get("linkText")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a data-bind="text:linkText,attr:{href:linkUrl,title:linkText}"/> | |
<span class="changed-label" data-bind="toggle:any(isNew, edited)">Changed</span> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var BindingView = Backbone.Epoxy.View.extend({ | |
bindings: { | |
"a": "text:linkText,attr:{href:linkUrl,title:linkText}" | |
} | |
}); | |
var model = new Backbone.Model({ | |
linkText:"use Epoxy for data binding in Backbone", | |
linkUrl:"http://epoxyjs.org/" | |
}); |
NewerOlder