1

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;

3
  • What's the JS error message? Or does it just silently fail? Have you tried debugging using the browser console?
    – Beebee
    Commented Jul 3, 2013 at 9:40
  • No errors, console.log('test') works only when compression is Off :/
    – Codium
    Commented Jul 3, 2013 at 10:03
  • Have you tried drupal_add_js instead to see if that solves your issue?
    – mariomc
    Commented Jul 3, 2013 at 16:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.