← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4178: Ajax Request stuff don't work does not work with IE9 ( Multi Selection Organisation Unit ).

 

------------------------------------------------------------
revno: 4178
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-07-21 14:11:13 +0700
message:
  Ajax Request stuff don't work does not work with IE9 ( Multi Selection Organisation Unit ).
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js	2011-04-24 08:26:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js	2011-07-21 07:11:13 +0000
@@ -47,34 +47,46 @@
         {
             onSelectFunction();
         }
-        
-        var request = new Request();
-        request.setCallbackSuccess( responseReceived );
-        request.setResponseTypeXML( 'selected' );
-        
+		
         var unitTag = document.getElementById( getTagId( unitId ));
-        var linkTags = unitTag.getElementsByTagName( 'a' );
+        var linkTags = $(unitTag).find( 'a' );
 
         if ( linkTags[0].className == 'selected' )
         {
-            request.send( selectionTreePath + 'removeorgunit.action?id=' + unitId );
+			$.ajax({
+				url: selectionTreePath + 'removeorgunit.action?id=' + unitId,
+				cache: false,
+				dataType: "xml",
+				success: responseReceived
+			});
+				
             linkTags[0].className = '';			
         }
         else
         {			
-			
             if ( multipleSelectionAllowed )
             {
-                request.send( selectionTreePath + 'addorgunit.action?id=' + unitId );
-                linkTags[0].className = 'selected';
+                $.ajax({
+					url: selectionTreePath + 'addorgunit.action?id=' + unitId,
+					cache: false,
+					dataType: "xml",
+					success: responseReceived
+				});
+				
+				linkTags[0].className = 'selected';
             }
             else
             {
-                request.send( selectionTreePath + 'setorgunit.action?id=' + unitId );
-                    
+                $.ajax({
+					url: selectionTreePath + 'setorgunit.action?id=' + unitId,
+					cache: false,
+					dataType: "xml",
+					success: responseReceived
+				});
+				
                 // Remove all select marks
                 var treeTag = document.getElementById( 'selectionTree' );
-                var linkTags = treeTag.getElementsByTagName( 'a' );
+                var linkTags = $(treeTag).find( 'a' );
 
                 for ( var i = 0, linkTag; ( linkTag = linkTags[i] ); ++i )
                 {
@@ -83,7 +95,7 @@
 
                 // Set new select mark
                 var unitTag = document.getElementById( getTagId( unitId ));
-                linkTags = unitTag.getElementsByTagName( 'a' );
+                linkTags = $(unitTag).find( 'a' );
                 linkTags[0].className = 'selected';
             }
         }
@@ -95,7 +107,7 @@
 	
 		var unitIds = new Array();
 
-        var unitIdElements = rootElement.getElementsByTagName( 'unitId' );
+        var unitIdElements = $(rootElement).find( 'unitId' );
         
         for ( var i = 0, unitIdElement; ( unitIdElement = unitIdElements[i] ); ++i )
         {
@@ -139,7 +151,7 @@
     this.toggle = function( unitId )
     {
         var parentTag = document.getElementById( getTagId( unitId ));
-        var children = parentTag.getElementsByTagName( 'ul' );
+        var children = $(parentTag).find( 'ul' );
 
         var request = new Request();
         request.setResponseTypeXML( 'units' );
@@ -164,27 +176,29 @@
         
         setLoadingMessage( treeTag );
         
-        var children = treeTag.getElementsByTagName( 'ul' );
+        var children = $(treeTag).find( 'ul' );
         if ( children.length > 0 )
         {
             treeTag.removeChild( children[0] );
         }
-
-        var request = new Request();
-        request.setResponseTypeXML( 'units' );
-        request.setCallbackSuccess( treeReceived );
-        request.send( selectionTreePath + 'getExpandedTree.action' );
+		
+		$.ajax({
+			url: selectionTreePath + 'getExpandedTree.action',
+			cache: false,
+			dataType: "xml",
+			success: treeReceived
+		});
     };
 
     function processExpand( rootElement )
     {
-        var parentElements = rootElement.getElementsByTagName( 'parent' );
+        var parentElements = $(rootElement).find( 'parent' );
 
         for ( var i = 0, parentElement; ( parentElement = parentElements[i] ); ++i )
         {
             var parentId = parentElement.getAttribute( 'parentId' );
             var parentTag = document.getElementById( getTagId( parentId ));
-            var children = parentTag.getElementsByTagName( 'ul' );
+            var children = $(parentTag).find( 'ul' );
 
             if ( children.length < 1 )
             {
@@ -200,8 +214,8 @@
 
     function treeReceived( rootElement )
     {
-        var rootsElement = rootElement.getElementsByTagName( 'roots' )[0];
-        var unitElements = rootsElement.getElementsByTagName( 'unit' );
+		var rootsElement = $(rootElement).find( 'roots' ).first();
+        var unitElements = $(rootElement).find( 'unit' );
         
         var treeTag = document.getElementById( 'selectionTree' );
         var rootsTag = document.createElement( 'ul' );
@@ -215,8 +229,8 @@
 
         treeTag.appendChild( rootsTag );
 
-        var childrenElement = rootElement.getElementsByTagName( 'children' )[0];
-        var parentElements = childrenElement.getElementsByTagName( 'parent' );
+        var childrenElement = $(rootElement).find( 'children' ).first();
+        var parentElements = $(childrenElement).find( 'parent' );
 
         for ( var i = 0, parentElement; ( parentElement = parentElements[i] ); ++i )
         {
@@ -231,7 +245,7 @@
 
     function createChildren( parentTag, parentElement )
     {
-        var children = parentElement.getElementsByTagName( 'child' );
+        var children = $(parentElement).find( 'child' );
         var childrenTag = document.createElement( 'ul' );
 
         for ( var i = 0, child; ( child = children[i] ); ++i )
@@ -292,7 +306,7 @@
 
     function setToggle( unitTag, expanded )
     {
-        var spans = unitTag.getElementsByTagName( 'span' );
+        var spans = $(unitTag).find( 'span' );
         var toggleTag = spans[0];
         var toggleImg = expanded ? getToggleCollapse() : getToggleExpand();