.delegate() a selector representing the target element is required.
$("#file").delegate('.selector_of_element_to_watch', "change", function() {
$("#submit_form").trigger('click');
});
If the item #fileis the one that should trigger the change event, then do not use .delegate.
$("#file").bind("change", function() {
$("#submit_form").trigger('click');
});
The reason for this is that the delegate handler is placed on the ancestor of the element that should trigger the event. Then you provide a selector for this element.
. , , , window, .
, , , , , , . , . , .
jQuery 1.7 - on.
.
, :
$("#file").on( "change", '.selector_of_element_to_watch', function() {
$("#submit_form").trigger('click');
});
:
$("#file").on( "change", function() {
$("#submit_form").trigger('click');
});
( , #file , , / . , , , .)
API- bind/live/delegate, , .