Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
143
rated 0 times [  146] [ 3]  / answers: 1 / hits: 30212  / 15 Years ago, tue, may 12, 2009, 12:00:00

I have a webpage with a form element and a popup window (opened by window.open).



Both have jQuery available.



The popup window has a javascript that can change the form element in the opener window. That works perfectly by doing...



$(opener.document.formelement).val(vals[0]);


However by doing that the onChange event will not fire. That would be required by some other page elements, though. So I tried to fire the onChange event myself with



$(opener.document.formelement).change();


But that doesn't do anything.



Any hints? I definitely have to have that onChange event fired due to the architecture of other page elements.



This question is similar to Call Javascript onchange event by programatically changing textbox value, but the suggested solutions from that question don't seem to work for me. Maybe that's because of the popup.


More From » jquery

 Answers
10

Perhaps its the cross-window that is hurting you... Try making a function inside of opener that you call instead. Might help?



In opener:



window.changeMyElement = function(value) {
$(formelement).val(value).change();
}


From popup:



opener.changeMyElement(value);

[#99549] Thursday, May 7, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jimmieo

Total Points: 515
Total Questions: 102
Total Answers: 110

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
;