<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>How to assign value to a textarea out of ajaxable plugin</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>
<P><TT><FONT SIZE=2>Hi all,<BR>
<BR>
I know, that this might be a dumb question, but I'm lost and I don't find any solution by myself. I wrote my own plugin, which should write something into a textarea if the user selects something in a dropdown list. Without Ajax, no problem, but I can't find out how to do it with Ajax. Here are the details:<BR>
<BR>
In cartoclient.tpl I defined the dropdown menu and the textarea:<BR>
<BR>
<select name="col" onchange="javascript:CartoWeb.trigger('refsel.submit','formItemSelected()');"><BR>
{html_options values=$col_values output=$col_output selected=$col}<BR>
</select><br /><BR>
Selection:<br /><textarea type="text" name="selection" cols="30" rows="10" >{$current_selection}</textarea><br /><BR>
<BR>
<BR>
Then I defined a new plugin called refsel, which implements ajaxable. The implementing methods:<BR>
<BR>
/*<BR>
* Ajaxable methods<BR>
*/<BR>
public function ajaxHandleAction($actionName,PluginEnabler $pluginEnabler){<BR>
switch($actionName){<BR>
case refsel.submit:<BR>
$pluginsDirectives->disableCoreplugins();<BR>
$pluginsDirectives->enablePlugin('refsel');<BR>
break;<BR>
}<BR>
}<BR>
<BR>
public function ajaxGetPluginResponse(AjaxPluginResponse $ajaxPluginResponse){<BR>
$ajaxPluginResponse->addVariable('sel','HelloWorld');<BR>
}<BR>
<BR>
In refsel.ajax.js I defined:<BR>
<BR>
AjaxPlugins.refsel = {<BR>
handleResponse: function(pluginOutput){<BR>
$('selection').current_selection=pluginOutput.variables.sel;<BR>
}<BR>
};<BR>
<BR>
/*<BR>
* Plugin Actions<BR>
*/<BR>
AjaxPlugins.refsel.Actions = {};<BR>
AjaxPlugins.refsel.Actions.submit = {<BR>
buildPostRequest: function(argObject){<BR>
return AjaxHandler.buildPostRequest();<BR>
},<BR>
buildGetRequest: function(argObject){<BR>
return '';<BR>
},<BR>
onBeforeAjaxCall: function(argObject){<BR>
},<BR>
onAfterAjaxCall: function(argObject){<BR>
}<BR>
}<BR>
<BR>
I know, there has to be something wrong with handleResponse, since I get<BR>
<BR>
Error: AjaxHandler.actionRequest(): received response is malformed!<BR>
<BR>
when I try to use the plugin. I tried several different versions of handleResponse, but I can't find out how to do it the right way.<BR>
<BR>
Is there somebody, who can help me with this little (but annoying) problem? I would be very grateful :-)<BR>
<BR>
Thanks in Advance!<BR>
Carolin</FONT></TT>
</P>
</BODY>
</HTML>