Enforce selection of an Authority in Registration
authorLoic Baron <loic.baron@lip6.fr>
Thu, 16 Jan 2014 16:53:44 +0000 (17:53 +0100)
committerLoic Baron <loic.baron@lip6.fr>
Thu, 16 Jan 2014 16:53:44 +0000 (17:53 +0100)
portal/templates/registration_view.html

index b14e2d2..7ed1bd1 100644 (file)
@@ -114,9 +114,18 @@ jQuery(document).ready(function(){
         {value:"",label:"No authority found !!!"}
     {% endif %}
     ];
-    $( "#authority_hrn" ).autocomplete({
+    jQuery( "#authority_hrn" ).autocomplete({
       source: availableTags,
-      select: function( event, ui ) {console.log(jQuery(this))}
+      minLength: 0,
+      change: function (event, ui) {
+          if(!ui.item){
+              //http://api.jqueryui.com/autocomplete/#event-change -
+              // The item selected from the menu, if any. Otherwise the property is null
+              //so clear the item for force selection
+              jQuery("#authority_hrn").val("");
+          }
+      }
+      //select: function( event, ui ) {console.log(jQuery(this))}
     });
 });
 </script>