Details
-
Bug
-
Resolution: Fixed
-
Major
-
3.0
-
None
-
livetable ajax actions callback
-
Unknown
-
Description
If you specify 2 or more livetable actions with ajaxAction set to true, the AjaxRequest that is executed (before calling the callback function) when you click on the action uses the URL of the last action in the list instead of the URL of the action that was clicked.
At line 1580 in macros.vm:
var link = new Element("a", {"href": row.doc_${action}_url, "class":"action action${action}"}).update("$text"); #if("$!colprop.ajaxActions.get($action)" == 'true') link.observe('click', function(event) { event.stop(); new Ajax.Request(link.href, { onSuccess : function() { $colprop.actionCallbacks.get($action) } }); }); #end
link.href points to the last action in a row, instead of the action that is clicked. Probably it's a JS issue where the link variable gets overridden and the callback uses the overridden value.
A quick solution suggested by Jerome is to use row.doc_${action}_url instead of link.href. Tested it and it works as expected. Making a pull request soon.
The only downside of this is that the link variable remains invalid and, if the code of the actionCallback uses it, the result will be unexpected. On the other hand, this is completely internal behavior and the actionCallback code should not rely on internal variables.