Because old messages with errors doesn't disappear after next, success upload, I want to remove them by this method.
JS file in custom module:
(function ($) {
/**
* Attach behaviors to the file upload and remove buttons.
*/
Drupal.behaviors.fileButtons = {
attach: function (context) {
$('input.form-submit', context).bind('mousedown', Drupal.file.disableFields);
$('div.form-managed-file input.form-submit', context).bind('mousedown', Drupal.file.progressBar);
$('div.form-managed-file input.form-submit', context).bind('mousedown', function() {
$(this).parent().parent().parent().parent().find('.messages').remove();
});
},
detach: function (context) {
$('input.form-submit', context).unbind('mousedown', Drupal.file.disableFields);
$('div.form-managed-file input.form-submit', context).unbind('mousedown', Drupal.file.progressBar);
}
};
}(jQuery));
module file:
function rpke_forms_form_node_form_alter(&$form, &$form_state) {
global $conf;
//$conf['preprocess_js'] = FALSE;
$form['#attached']['js'][] = drupal_get_path('module', 'rpke_forms') . '/rpke_forms.js';
}
/**
* Implements hook_module_implements_alter
*/
function rpke_forms_module_implements_alter(&$module_list, $context){
if($context === 'form_node_form_alter'){
$temp = $module_list['rpke_forms'];
// Removing the mymodule key/value
unset($module_list['rpke_forms']);
// Adding the mymodule key value as the last member in the list
$module_list['rpke_forms'] = $temp;
}
}
Everything works as expected when JS compression is off, after enabling, it stops working. It's works all time, when I uncomment $conf['preprocess_js'] = FALSE;