diff --git a/~dev_rating/media/js/discipline/EditGroups.js b/~dev_rating/media/js/discipline/EditGroups.js index 1f8507d0f38e3dcde94e9596c7eea5a08d8c30b8..980d469e83ee799ed8dcc5e93ea2dd1bffb7d4f3 100644 --- a/~dev_rating/media/js/discipline/EditGroups.js +++ b/~dev_rating/media/js/discipline/EditGroups.js @@ -10,19 +10,22 @@ function BindGroup(id, StudyGroupName){ } // Прикрепить группу -$('.AttachGroupButton').click(function(){ - var StudyGroupID = $('.SelectStudyGroup').val(); - var StudyGroupName = $(".SelectStudyGroup option:selected").text(); +$('.AttachGroupButton').click(function() +{ + var jSelector = $(this).prev(); + var StudyGroupID = jSelector.val(); + var StudyGroupName = jSelector.children("option:selected").first().text(); $.post( URLdir + 'handler/map/BindGroup', { 'StudyGroupID': StudyGroupID, 'DisciplineID': DisciplineID }, - function(data){ + function(data) + { data = $.parseJSON(data); if(data.success === true) { - $('.AttachedGroupsList').append(BindGroup(StudyGroupID, StudyGroupName)); + jSelector.parent().next().append(BindGroup(StudyGroupID, StudyGroupName)); EventInspector_ShowMsg('Группа добавлена', 'success'); } else EventInspector_ShowMsg('Ошибка при добавление группы', 'error'); @@ -31,16 +34,18 @@ $('.AttachGroupButton').click(function(){ }); // Отсоединить группу -$('.AttachedGroupsList').on('click', '.UnbindGroup', function(){ - var StudyGroupID = $(this).parent().attr('id'); +$('.AttachedGroupsList').on('click', '.UnbindGroup', function() +{ var GroupDIV = $(this).parent(); + var StudyGroupID = GroupDIV.attr('id'); $.post( URLdir + 'handler/map/UnbindGroup', { 'StudyGroupID': StudyGroupID, 'DisciplineID': DisciplineID }, - function(data){ + function(data) + { data = $.parseJSON(data); if(data.success === true) { GroupDIV.remove();