<commit_before>"use strict";


var PickerView = Backbone.View.extend({


	$template: $($.parseHTML(
		$('script#picker[type="template/html"]').text()
	)),


	initialize: function (options) {

		this.attributeName = options.attributeName;
		this.$('.js-title').text(options.title);
		// this.$el.addClass(options.class);

		this.ItemView = options.ItemView;
		this.$ul = this.$('.js-items')

		this.collection.on('add', this.add, this);
		this.collection.each(this.add, this);
	},


	add: function (model) {

		model.on('select', function () {

			this.model.set(this.attributeName, model.id);

		}.bind(this))

		// TODO: Leaking views.
		var view = new this.ItemView({
			model: model,
			initallySelectedValue: this.model.get(this.attributeName)
		});

		view.$el.appendTo(this.$ul);
	}

});<commit_msg>Fixed view leak.<commit_after>"use strict";


var PickerView = Backbone.View.extend({


	$template: $($.parseHTML(
		$('script#picker[type="template/html"]').text()
	)),


	initialize: function (options) {

		this.subviews = [];

		this.attributeName = options.attributeName;
		this.$('.js-title').text(options.title);
		// this.$el.addClass(options.class);

		this.ItemView = options.ItemView;
		this.$ul = this.$('.js-items')

		this.collection.on('add', this.add, this);
		this.collection.each(this.add, this);
	},


	add: function (model) {

		model.on('select', function () {

			this.model.set(this.attributeName, model.id);

		}.bind(this))

		var view = new this.ItemView({
			model: model,
			initallySelectedValue: this.model.get(this.attributeName)
		});

		view.$el.appendTo(this.$ul);

		this.subviews.push(view);
	}

});
{'fraction_non_alphanumeric': 0.19463087248322147, 'fraction_numerical': 0.0, 'mean_word_length': 3.880952380952381, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2093922', 'n_tokens_mistral': 632, 'n_tokens_neox': 556, 'n_words': 89}