var App_AdminVolunteer_Form = { originalType: null, isConfirmedGroupChanges: false, initialize: function(options) { if (!empty(options.type)) { this.originalType = options.type; } if (!empty(this.originalType)) { var obj = this; $('select#type').change(function(){ var newValue = $(this).val(); if (newValue !== obj.originalType && !obj.isConfirmedGroupChanges) { if ('board' == newValue || 'board' == obj.originalType) { obj.showTypeChangeAttention(); } } }); } }, showTypeChangeAttention: function() { var position = 'board' == this.originalType ? 'Member' : 'Director'; var res = confirm( 'You change the type of whole group. After submitting this form all members of current group would set to "' + position + '" position. ' + "\n" + "Are you sure you want to change group type?" ); if (!res) { $('select#type').val(this.originalType); } else { this.isConfirmedGroupChanges = true; } } }