<commit_before>// 
$(function() {

	var UserModel = Backbone.Model.extend({
		defaults: function() {
			return {
				id: null,
				name: "<NAME>",
				age: 18 + parseInt(Math.random() * 20),
				employed: "No"
			};
		},

		validate: function(attributes) {
			if (!_.isNumber(attributes.age) || _.isNaN(attributes.age)) {
				return "Age is not a number";
			}

			if (attributes.age < 18) {
				return "Sorry, just 18 and older";
			}
		}
	});

	var UserCollection = Backbone.Collection.extend({
		model: UserModel
	});

	var users = new UserCollection();
	users.on("add", userAdded);

	function userAdded(){
		var template = $("[data-template-name='user-row']").html().trim();

		$tbody = $(".users-table > tbody");

		$tbody.empty();

		users.each(function(user){
			$tbody.append(Mustache.render(template, user.toJSON()));
		});
	};

	$(".add").click(function(event) {
		var user = new UserModel({
			name: $("input[name='name']").val(),
			age: parseInt($("input[name='age']").val()),
			employed: $("input[name='employed']").is(":checked") ? "Yes" : "No"
		});

		users.add(user);
	});
});<commit_msg>Los cambios de este ejemplo no se tenian que ir al repo :(<commit_after>// 
$(function() {

	var UserModel = Backbone.Model.extend({
		defaults: function() {
			return {
				id: null,
				name: "<NAME>",
				age: 18 + parseInt(Math.random() * 20),
				employed: "No"
			};
		},

		validate: function(attributes) {
			if (!_.isNumber(attributes.age) || _.isNaN(attributes.age)) {
				return "Age is not a number";
			}

			if (attributes.age < 18) {
				return "Sorry, just 18 and older";
			}
		}
	});

	var UserCollection = Backbone.Collection.extend({
		model: UserModel
	});

	var users = new UserCollection();

	$(".add").click(function(event) {
		var user = new UserModel({
			name: $("input[name='name']").val(),
			age: parseInt($("input[name='age']").val()),
			employed: $("input[name='employed']").is(":checked") ? "Yes" : "No"
		});
		console.log(user);
	});
});
{'fraction_non_alphanumeric': 0.21262626262626264, 'fraction_numerical': 0.00808080808080808, 'mean_word_length': 3.5228310502283104, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4302083', 'n_tokens_mistral': 810, 'n_tokens_neox': 676, 'n_words': 148}