From 824f9ddf5ac3c5d8f46fa8a3bcd49456aa9f0e22 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 31 Jul 2013 12:29:07 +0200 Subject: [PATCH] =?utf8?q?ClientJS:=20Funktionen=20zum=20Hinzuf=C3=BCgen?= =?utf8?q?=20und=20Entfernen=20generischer=20Eventhandler?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/ClientJS.pm | 16 +++++++++++++++- js/client_js.js | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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 -- 2.20.1