← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7308: Minor fix.

 

------------------------------------------------------------
revno: 7308
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-06-15 12:37:59 +0700
message:
  Minor fix.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.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-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-06-15 04:55:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-06-15 05:37:59 +0000
@@ -753,7 +753,7 @@
 				
 		jQuery("#entryForm :input").each(function()
 		{ 
-			if( jQuery(this).attr( 'options' )!= null )
+			if( jQuery(this).attr( 'options' )!= null && jQuery(this).attr( 'options' )== 'true' )
 			{
 				autocompletedField(jQuery(this).attr('id'));
 			}
@@ -846,6 +846,25 @@
 				input.val(ui.item.value);
 				saveVal( dataElementId );
 				input.autocomplete( "close" );
+			},
+			change: function( event, ui ) {
+				if ( !ui.item ) {
+					var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
+						valid = false;
+					select.children( "option" ).each(function() {
+						if ( $( this ).text().match( matcher ) ) {
+							this.selected = valid = true;
+							return false;
+						}
+					});
+					if ( !valid ) {
+						// remove invalid value, as it didn't match anything
+						$( this ).val( "" );
+						select.val( "" );
+						input.data( "autocomplete" ).term = "";
+						return false;
+					}
+				}
 			}
 		})
 		.addClass( "ui-widget" );