I have created a block in which I display a flag. All of it is done programatically. The content of the block changes depending on the flag status, but when a user clicks on the flag, it does not refresh the page or the block. The content is currently refreshed only when I reload the page.
I have gone as far as to create a callback from my block module to a jquery file, but I do not quite know where to go from here. I am not familiar enough with jquery to fully understand what to do, and how to use the callback function. Here is what I have thus far in my .module file:
/**
* Implements hook_init().
*/
function mymodule_init() {
drupal_add_library('system', 'drupal.ajax');
}
/**
* Implements hook_menu().
*/
function mymodule_menu() {
$items = array();
$items['block/reload'] = array(
'title' => 'Refresh block',
'page callback' => 'mymodule_refresh',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Menu callback.
*/
function mymodule_refresh($action, $type) {
}
In a .js file which I have put in a folder 'js' in my module's folder, I have created this:
(function($){
$(document).bind('flagGlobalAfterLinkUpdate', function(event, data) {
}
});
})(jQuery);