Is there any simple way to set / unset flags using JavaScript or jQuery?. I thought this would be easy, by doing something like
var action = Drupal.settings.basePath + 'flag/flag/myFlagType/' + nid;
$.ajax({url:action});
But this gives me a message "Undefined index: token in flag_page()", together with "Access denied". So obviously I have to provide a (session?) token, but I've no idea how to achieve this.
Explanation:
I don't want to use the builtin JS flag links, no links at all, but implement some kind of drag&drop interface using jQuery UI. So I have to implement something like "Flag element, when dropped".
Looked at the Javascript API Docs, but there's no hint about flagging / unflagging, only on how to react on flagging.
Any way, or undocumented function?
Thanks a lot!
Comments
Comment #1
qasimzee CreditAttribution: qasimzee commentedComment #2
sashken2 CreditAttribution: sashken2 commentedHow to flag / unflag using only JavaScript (without jQuery) in Drupal 8 ?