mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
calling jquery as part of a response, eg. ->call('#123','addClass',array('valid'));
This commit is contained in:
parent
7eb21252af
commit
feaab09818
@ -271,10 +271,30 @@ class egw_json_response
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to add a global javascript function with giben parameters
|
||||
*
|
||||
* @param string $script the script code which should be executed upon receiving
|
||||
*/
|
||||
public function each($selector,$method,array $parameters=array())
|
||||
{
|
||||
if (is_string($selector) && is_string($method))
|
||||
{
|
||||
$this->addGeneric('each', array(
|
||||
'select' => $selector,
|
||||
'func' => $method,
|
||||
'params' => $parameters,
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid parameters supplied.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an html assign to the response, which is excecuted upon the request is received.
|
||||
*
|
||||
* @deprecated just for compatibility with XAJAX
|
||||
* @param string $id id of dom element to modify
|
||||
* @param string $key attribute name of dom element which should be modified
|
||||
* @param string $value the value which should be assigned to the given attribute
|
||||
|
@ -184,6 +184,26 @@ egw_json_request.prototype.handleResponse = function(data, textStatus, XMLHttpRe
|
||||
hasResponse = true;
|
||||
}
|
||||
break;
|
||||
case 'each':
|
||||
if (typeof data.response[i].select == 'string' && typeof data.response[i].func == 'string')
|
||||
{
|
||||
try
|
||||
{
|
||||
var func = data.response[i].func;
|
||||
// todo: for N>2
|
||||
$(data.response[i].select).each(func.call(data.response[i].parms[0],data.response[i].parms[1],data.response[i].parms[2]));
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
if (typeof console != "undefined" && typeof console.log != "undefined")
|
||||
{
|
||||
e.code = data.response[i];
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
hasResponse = true;
|
||||
}
|
||||
break;
|
||||
case 'redirect':
|
||||
if (typeof data.response[i].data == 'string')
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user