<commit_before>
define([
	'marionette',
	'marionette.formview',
	'text!module/account/template/modifyAccountView.html'
], function(Marionette, MarionetteFormView, ModifyAccountTemplate)
{
	var accountModified = false;

	var ModifyAccountView = Marionette.FormView.extend(
	{
		template: ModifyAccountTemplate,

		initialize: function (options)
		{
			this.listenTo(this.model, 'account:save:success', this.onAccountSave);
		},

		/**
		 * Declare variables to access template content
		 */
		ui: {
			firstname: '#account-firstname',
			lastname: '#account-lastname',
			deletemodal: '#account-delete-modal'
		},

		/**
		 * Catch events
		 */
		events: {
			'click #account-delete-btn': 'showDeleteAccountModal',
			'click #account-delete-modal-ok': 'onAccountDelete'
		},

		/**
		 * Declare inputs
		 */
		fields: {
			firstname: {
				el: 'firstname'
			},
			lastname: {
				el: 'lastname'
			}
		},

		/**
		 * Delete my account
		 */
		onAccountDelete: function (evt)
		{
			evt.preventDefault();

			var app = this.options.app;

			this.ui.deletemodal.modal('hide');

			this.model.destroy({
				'success': function ()
				{
					app.vent.trigger('page:logout');
				}
			});
		},

		/**
		 * What to do when account information has been save
		 */
		onAccountSave: function ()
		{
			accountModified = true;
			this.render();
		},

		onRender: function ()
		{
			window.setTimeout(function()
			{
				$(".alert-success").alert('close');
			}, 5000);
		},

		/**
		 * Save model when submit me
		 */
		onSubmit: function (evt)
		{
			evt.preventDefault();

			this.model.set(this.serializeFormData()).savedata();
		},

		serializeData: function ()
		{
			var app = this.options.app;

			return $.extend({}, this.model.toJSON(), {
				accountModified: accountModified,
				url: app.url
			});
		},

		/**
		 * Show delete account confirmation
		 */
		showDeleteAccountModal: function (evt)
		{
			this.ui.deletemodal.modal('show');
		}

	});

	return ModifyAccountView;
});<commit_msg>prevent view to reload itself when clicking on delete account button<commit_after>
define([
	'marionette',
	'marionette.formview',
	'text!module/account/template/modifyAccountView.html'
], function(Marionette, MarionetteFormView, ModifyAccountTemplate)
{
	var accountModified = false;

	var ModifyAccountView = Marionette.FormView.extend(
	{
		template: ModifyAccountTemplate,

		initialize: function (options)
		{
			this.listenTo(this.model, 'account:save:success', this.onAccountSave);
		},

		/**
		 * Declare variables to access template content
		 */
		ui: {
			firstname: '#account-firstname',
			lastname: '#account-lastname',
			deletemodal: '#account-delete-modal'
		},

		/**
		 * Catch events
		 */
		events: {
			'click #account-delete-btn': 'showDeleteAccountModal',
			'click #account-delete-modal-ok': 'onAccountDelete'
		},

		/**
		 * Declare inputs
		 */
		fields: {
			firstname: {
				el: 'firstname'
			},
			lastname: {
				el: 'lastname'
			}
		},

		/**
		 * Delete my account
		 */
		onAccountDelete: function (evt)
		{
			evt.preventDefault();

			var app = this.options.app;

			this.ui.deletemodal.modal('hide');

			this.model.destroy({
				'success': function ()
				{
					app.vent.trigger('page:logout');
				}
			});
		},

		/**
		 * What to do when account information has been save
		 */
		onAccountSave: function ()
		{
			accountModified = true;
			this.render();
		},

		onRender: function ()
		{
			window.setTimeout(function()
			{
				$(".alert-success").alert('close');
			}, 5000);
		},

		/**
		 * Save model when submit me
		 */
		onSubmit: function (evt)
		{
			evt.preventDefault();

			this.model.set(this.serializeFormData()).savedata();
		},

		serializeData: function ()
		{
			var app = this.options.app;

			return $.extend({}, this.model.toJSON(), {
				accountModified: accountModified,
				url: app.url
			});
		},

		/**
		 * Show delete account confirmation
		 */
		showDeleteAccountModal: function (evt)
		{
			evt.preventDefault();

			this.ui.deletemodal.modal('show');
		}

	});

	return ModifyAccountView;
});
{'fraction_non_alphanumeric': 0.15350553505535056, 'fraction_numerical': 0.0019680196801968018, 'mean_word_length': 3.005911330049261, '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': '1217456', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1326, 'n_words': 249}