[Cartoweb-users] How to assign value to a textarea out of ajaxable
plugin
LATZE Carolin
carolin.latze at unifr.ch
Fri Nov 30 13:42:28 EST 2007
Hi all,
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:
In cartoclient.tpl I defined the dropdown menu and the textarea:
<select name="col" onchange="javascript:CartoWeb.trigger('refsel.submit','formItemSelected()');">
{html_options values=$col_values output=$col_output selected=$col}
</select><br />
Selection:<br /><textarea type="text" name="selection" cols="30" rows="10" >{$current_selection}</textarea><br />
Then I defined a new plugin called refsel, which implements ajaxable. The implementing methods:
/*
* Ajaxable methods
*/
public function ajaxHandleAction($actionName,PluginEnabler $pluginEnabler){
switch($actionName){
case refsel.submit:
$pluginsDirectives->disableCoreplugins();
$pluginsDirectives->enablePlugin('refsel');
break;
}
}
public function ajaxGetPluginResponse(AjaxPluginResponse $ajaxPluginResponse){
$ajaxPluginResponse->addVariable('sel','HelloWorld');
}
In refsel.ajax.js I defined:
AjaxPlugins.refsel = {
handleResponse: function(pluginOutput){
$('selection').current_selection=pluginOutput.variables.sel;
}
};
/*
* Plugin Actions
*/
AjaxPlugins.refsel.Actions = {};
AjaxPlugins.refsel.Actions.submit = {
buildPostRequest: function(argObject){
return AjaxHandler.buildPostRequest();
},
buildGetRequest: function(argObject){
return '';
},
onBeforeAjaxCall: function(argObject){
},
onAfterAjaxCall: function(argObject){
}
}
I know, there has to be something wrong with handleResponse, since I get
Error: AjaxHandler.actionRequest(): received response is malformed!
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.
Is there somebody, who can help me with this little (but annoying) problem? I would be very grateful :-)
Thanks in Advance!
Carolin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20071130/be9a3bd0/attachment.html
More information about the Cartoweb-users
mailing list