I have a node flag abuse and I want to remove/hide unflag link text "non-abuse" once the abuse flag is set.
How to do this in Drupal? Since I am new to Drupal, I can't think of a solution for this.
Note: I'm using this inside the Panels module.
In Drupal 7 you can use The Flag API (JavaScript) for this
The flagGlobalAfterLinkUpdate event : This event is triggered immediately after a flag link has been updated. (Flag links appear in two flavors: "Bookmark this!" and "Unbookmark this!", and when we speak of "update" we mean this change in appearance).
(function ($) {
$(document).bind('flagGlobalAfterLinkUpdate', function(event, data) {
if (data.flagName == 'yourFlagName' && data.flagStatus == 'flagged') { //dont forget to add your flag name
var flgName = '.flag-'+data.flagName;
$(flgName).hide('slow');
}
});
})(jQuery);
In the flag settings page under FLAG ACCESS
you have Roles that may use this flag
Just un-check UNFLAG
option for all the roles.
So u are using Panels. It would be better to add a visibility criteria on the flag link block.
For that, go to that block on the panels page -> Click on Visibility rule -> Click on Add a new Rule -> Check on Content is flagged.
So when u hit save it would show you all the flags that are there.
In my case it shows this
So select the desired flag and check the Reverse(Not) checkbox.
Hit save and it would serve your purpose.
I am new to Drupal Javascript, but try this. https://www.drupal.org/docs/7/api/javascript-api/managing-javascript-in-drupal-7
Declare JS in root theme .info file - put mycustomjs.js in theme root folder
(function ($) {
Drupal.behaviors.exampleModule = { attach: function (context, settings) { // Code to be run on page load, and // on ajax load added here } }; }(jQuery));