Closed (fixed)
Project:
FileField
Version:
6.x-3.7
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
10 Sep 2010 at 14:50 UTC
Updated:
24 Sep 2010 at 20:50 UTC
Hi,
I would like to chande the behaviour of the "Upload" and the "Remove" buttons. I would like them to listen to the mouseup-event instead of the mousedown-event. The best solution would be if I could acomplish this through my own module.
I got it working through a patch of the fielefield_widget.inc. Than I tried to make the changes inside a pre_render function but this has no effects.
How I tried it (and it does not work):
function module_name_form_alter(&$form, $form_state, $form_id) {
.
.
.
$form['field_name']['#pre_render'][] = 'module_name_alter_ahah';
.
.
.
}
function module_name_alter_ahah($elements){
$elements[0]['filefield_upload']['#ahah']['event'] = 'mouseup';
return $elements;
}
Any ideas how to accomplish this?
Thanks,
dendie
Comments
Comment #1
braindrift commentedComment #2
quicksketchI don't think this is possible. There was a long thread about how "click" events don't work properly for buttons as a #ahah property, otherwise that would be used instead of "mousedown". "mouseup" won't work at all because the form has already been submitted during the "click" event and "mouseup" is fired afterwards, meaning that the form would already be submitted normally without JavaScript by the time "mouseup" fires.
Comment #3
braindrift commentedbut it works fine when I add an
'event' => 'mouseup'in filefield_widget_process functionComment #4
quicksketchHm, well if you want to give it a shot you can implement hook_elements() and add your own #process function to FileField elements. This allows you to add your own processing (and change the #ahah property) after filefield_widget_process() has already run.
Comment #5
braindrift commentedThanks for the hint. That works!!!
Comment #6
braindrift commentedComment #7
braindrift commented@quicksketch: Just to ensure, is that the right way, or would you suggest an other one?
Comment #8
braindrift commentedComment #9
quicksketchYou actually shouldn't need to call the normal *_widget_process() functions at all. Make sure your module has a "weight" value greater than imagefield and filefield in the "system" database table, then you should just be able to do this:
The #process callbacks are merged recursively from hook_elements(), you just have to make sure that yours comes after filefield/imagefield.
Comment #10
braindrift commentedThanks!