I'm trying to insert additional AJAX commands when a Flag link is toggled. The flags link type is 'JavaScript toggle'.
Hooking into the Flag callback seems simple enough using hook_flag.
function hook_flag($op, $flag, $content_id, $account, $fcid) {
if ($flag->name == 'flag_name') {
// Additional Ajax Commands
}
}
The AJAX command I'm looking to include is:
ajax_command_replace("#div_id_to_replace", 'New content');
Is it possible to insert AJAX using hook_flag? If not, what would be the most appropriate way to swap out div content (in addition to the actual Flag AJAX) without a page reload when a Flag link is toggled?
Update: Found the Flag API (JavaScript) page while crawling through the docs. Hopefully will have an answer to add shortly.