如何从backbone.js中View对象的当前模板中获取所有输入元素,以便我可以检查输入元素中的值。
/*template*/
<script id="emptemplate" type="text/template">
<input id="name" value="{name}"/>
<input id="address" value="{address}"/>
<input id="sex" value="{sed}"/>
<footer>
<button id="save">save</button>
</footer>
</script>
/*javascript*/
var EmployeeView = Backbone.View.extend({
...
render:function(){
....
},
events:{
"click #save": "saveData"
},
saveData: function (e) {
var Data = [];
$('input').each(function (value, key) {
/*my problem here:
cannot able to get the value of input element!
*/
var v = value;
var k = key;
});
}
});