Reputation: 41
There is a text element with change event attached through $('input.filename').bind('change', function(){...})
, and there is a popup which triggers this event by $('input.filename').trigger('onchange')|.change()
.
Exception: if change event attached through "onchange" attribute triggering works!
Attaching code looks:
input.change(function () {
var dims = {
'width': settings.previewWidth,
'height': settings.previewHeight
};
updateImagePreview(input, preview, dims);
});
Triggering code looks like this:
var input = $("input[name='any_name']", window.opener.document);
input
.val("<?=$choice ?>")
.trigger("onchange");
window.close();
Upvotes: 4
Views: 1715
Reputation: 30666
I don't understand completely the context but the correct event to trigger is change
and not onchange
with jquery.
input.trigger('change'); // not "onchange"
or
input.change();
Upvotes: 2
Reputation: 76870
You should simply do change() or trigger("change"):
var input = $("input[name='any_name']", window.opener.document);
input
.val("<?=$choice ?>")
.trigger("change");
or more simply
var input = $("input[name='any_name']", window.opener.document);
input
.val("<?=$choice ?>")
.change();
If you use jQuery <1.4 the event will not bubble up in Internet Explorer
Upvotes: 0