From: Moritz Bunkus Date: Wed, 31 Jul 2013 10:29:07 +0000 (+0200) Subject: ClientJS: Funktionen zum Hinzufügen und Entfernen generischer Eventhandler X-Git-Tag: release-3.1.0beta1~117 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=824f9ddf5ac3c5d8f46fa8a3bcd49456aa9f0e22;p=kivitendo-erp.git ClientJS: Funktionen zum Hinzufügen und Entfernen generischer Eventhandler --- diff --git a/SL/ClientJS.pm b/SL/ClientJS.pm index 7eb092c47..0e18d732b 100644 --- a/SL/ClientJS.pm +++ b/SL/ClientJS.pm @@ -70,10 +70,15 @@ my %supported_methods = ( # Form Events focus => 1, + # Generic Event Handling ## pattern: $().(, kivi.get_function_by_name()) + on => 3, + off => 3, + one => 3, + # ## jqModal plugin ## # Closing and removing the popup - jqmClose => 1, + jqmClose => 1, # $().jqmClose() # ## jstree plugin ## pattern: $.jstree._reference($()).() @@ -464,6 +469,15 @@ C, C C +=item Generic Event Handlers + +C, C, C + +These attach/detach event listeners to specific selectors. The first +argument is the selector, the second the name of the events and the +third argument is the name of the handler function. That function must +already exist when the handler is added. + =back =head2 JSTREE JQUERY PLUGIN diff --git a/js/client_js.js b/js/client_js.js index 51e3638cd..e5fdcb578 100644 --- a/js/client_js.js +++ b/js/client_js.js @@ -86,6 +86,11 @@ ns.eval_json_result = function(data) { // Form Events else if (action[0] == 'focus') $(action[1]).focus(); + // Generic Event Handling ## + else if (action[0] == 'on') $(action[1]).on(action[2], kivi.get_function_by_name(action[3])); + else if (action[0] == 'off') $(action[1]).off(action[2], kivi.get_function_by_name(action[3])); + else if (action[0] == 'one') $(action[1]).one(action[2], kivi.get_function_by_name(action[3])); + // ## jqModal plugin ## // Closing and removing the popup