define([
	'Global',
	'Text!../html/templates/notification-pref.html'
],
function(Global, template){
	'use strict';

	return Backbone.View.extend({
		tagName: "ul",
		attributes: {
			'data-role': 'listview',
			'data-inset': 'true'
		},
		initialize: function(options){
			options = options || {};

			var that = this;

			this.model = options.model;
			this.template = _.template(template);
			this.listenTo(this.model, "update-preferences", function(){
				that.render();
			});
		},
		render: function(){
			var $container = $('.patient-contact');

			this.$el.empty().append(this.template(this.model.toJSON()));

			$container.append(this.$el).trigger('create');

			return this;
		}
	});
});