使用Backbone.js的和Rivets.js简单的例子 [英] Simple Example using Backbone.js and Rivets.js
问题描述
我要寻找一个非常简单的例子,例如有一个双向的跨度
文本和输入
使用Backbone.js的元素,的 Rivets.js 。或许有一个在Rivets.js文档,但我不能找到它。任何帮助吗?
I am looking for a very simple example where e.g. there is a two way binding between span
text and an input
element using Backbone.js and Rivets.js. Perhaps there is one in the Rivets.js docs, but I can't find it. Any help please?
推荐答案
假设你的意思是一个双向绑定(模型到视图,视图到模型)的输入元素和一个单向绑定(模型到视图)跨度的元素,则下面的视图会做你的描述。
Assuming that you mean a two-way binding (model-to-view and view-to-model) on an input element and a one-way binding (model-to-view) on a span element, then the following view will do what you describe.
<div id="user-view">
<span>{ user:name }</span>
<input rv-value="user:name">
</div>
这里是一个小提琴的实际行动体现了东西。它包括对 A骨干适配器:
接口,并说明如何在模型视图绑定(这仅仅是一个什么样已经显示在主页上更简单的例子)。
Here is a fiddle that demonstrates things in action. It includes a Backbone adapter on the :
interface and shows how to bind a model to the view (this is just a more trivial example of what is already shown on the homepage).
这篇关于使用Backbone.js的和Rivets.js简单的例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!