← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16039: in dhis2.selected plugin, disable search button when there is no text in search area. Change to u...

 

------------------------------------------------------------
revno: 16039
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-07-09 13:44:20 +0700
message:
  in dhis2.selected plugin, disable search button when there is no text in search area. Change to using keyup for events, since we want to fetch strign values directly from search area.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.selected.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/javascripts/dhis2/dhis2.selected.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.selected.js	2014-07-03 06:56:37 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.selected.js	2014-07-09 06:44:20 +0000
@@ -68,12 +68,14 @@
       context.source.on('scroll', context.makeScrollHandler(context));
 
       if( context.search instanceof $ ) {
-        context.search.on('keypress', context.makeSearchHandler(context));
-        var searchButton = $("#" + context.search.attr('id') + "Button");
+        context.search.on('keyup', context.makeSearchHandler(context));
+        context.searchButton = $("#" + context.search.attr('id') + "Button");
 
-        searchButton.on('click', function() {
-          context.search.trigger({type: 'keypress', which: 13, keyCode: 13});
+        context.searchButton.on('click', function() {
+          context.search.trigger({type: 'keyup', which: 13, keyCode: 13});
         });
+
+        context.searchButton.attr('disabled', true);
       }
     }
   };
@@ -128,6 +130,12 @@
     },
     makeSearchHandler: function( context ) {
       return function( e ) {
+        if( $(this).val().length > 0 ) {
+            context.searchButton.removeAttr( 'disabled' );
+        } else {
+            context.searchButton.attr( 'disabled', true );
+        }
+
         if( e.keyCode == 13 ) {
           context.page = 1;
           context.like = $(this).val();