Aralot (aralot) wrote in changelog,
Aralot
aralot
changelog

[livejournal] r17319: LJSUP-6572: js fix

Committer: szhirkov
LJSUP-6572: js fix
U   trunk/htdocs/js/reject.js
Modified: trunk/htdocs/js/reject.js
===================================================================
--- trunk/htdocs/js/reject.js	2010-09-09 08:23:28 UTC (rev 17318)
+++ trunk/htdocs/js/reject.js	2010-09-09 08:50:54 UTC (rev 17319)
@@ -30,23 +30,30 @@
 			
 			var currentControl = $(this),
 				elemToRemove = currentControl.closest('li'),
-				userId = currentControl.attr('id').replace(/\D+/g, '');
-			
+				userId = currentControl.attr('id').replace(/\D+/g, ''),
+				userListLength = _userList.find('li').length;
+				
+			if (userListLength === 1) {
+				return false;
+			}
+				
 			removeUserIdFromHidden(userId);
 			
 			elemToRemove.remove();
+			
 			removeUnwantedCommas();
 		}
 		
 		function removeUnwantedCommas () {
 			var userListLength = _userList.find('li').length,
-				firstUserElem, firstUserContent;
+				lastUserElem, lastUserContent;
 			
-			if (userListLength === 1) {
-				firstUserElem = _userList.first();
-				contentWithoutCommas = firstUserElem.html().replace(/\,/g, '');
-				firstUserElem.html(contentWithoutCommas);
-			}
+			lastUserElem = _userList.find('li').last();
+			contentWithoutCommas = lastUserElem.html().replace(/\,/g, '');
+			lastUserElem
+				.html(contentWithoutCommas)
+				.find(CONFIG.removeControlsSelector)
+					.click(removeUser);
 		}
 		
 		function removeUserIdFromHidden (userId) {

Tags: aralot, js, livejournal
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments