禁用列表中的所有复选框

时间:2015-08-12 13:42:58

标签: backbone.js

我的表格如下。

onRender: function (){
        var user = new models.User({'id': this.options.user_id});
        var userFetching = user.fetch({cache: false}).promise();
        self = this;

        $.when(userFetching).done(function(data){
            var form = new Backbone.Form({
                model: user //,
                //fields: ['username', 'email', 'password', 'domain', 'groups', 'id']
            }).render();

我需要禁用该特定表单下的所有复选框。

在backboneJS中如何实现?所有复选框都在< ul>标签

1 个答案:

答案 0 :(得分:0)

这应该有效

onRender= function() {
	var user = new models.User({
		'id': this.options.user_id
	});
	var userFetching = user.fetch({
		cache: false
	}).promise();
	self = this;

	$.when(userFetching).done(function(data) {
		var form = new Backbone.Form({
			model: user //,
				//fields: ['username', 'email', 'password', 'domain', 'groups', 'id']
		}).render();
                this.$el.find("#edit-user-form").find('input:checkbox').attr('disabled', true)
	})

	
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<form id="edit-user-form">
<input type="checkbox" name="vehicle" value="Bike">I have a bike<br>
<input type="checkbox" name="vehicle" value="Car">I have a car  
</form>