- ivnish Kazakhstan
3+ years without any activity. I think we can close it as outdated. Please reopen if needed.
I'm trying to run additional javascript code when specific flags are triggered on my site, eg User flags Node 1, this runs `runNodeFunction(id)`, User flags Paragraph 5, this runs `runParagraphFunction(id)` etc
I've already applied the patch from this page ✨ Allow AjaxResponse to be altered RTBC referring to opening up the AjaxResponse, and that patch seems to have gone in fine...
I've followed this tutorial to create a custom function to listen out for the Flag/Unflag actions on my site, which also seems to be working, I can make it spit out debug messages when the flag is triggered
I've also looked through this tutorial on how to edit the AjaxResponse object
The problem seems to be in tying it all together. if I try to add a new AjaxResponse object inside of the onFlag
functions outlined in the second link, it just doesn't seem to run anything at all when I click on the flag. Alternatively if I run a function from within the onResponse
outlined in the third link, I don't have enough information I can pull from the flag that triggered it, because I need to know the machine name of the flag, the entity it was flagged on, and the status.
Ideally I'm trying to create a custom module to wrap this in, because I will wish to re-use this configuration on multiple sites, and the machine names of the flags may vary from site to site, but the functions will remain the same
Is there a simpler way I'm missing of doing this?
Closed: outdated
Flag core
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
3+ years without any activity. I think we can close it as outdated. Please reopen if needed.