views:

24

answers:

2

Hi all,

I am not sure if this can be done. In the parent window, I have the following line,

<input type="hidden" name="myField" id="myField" value="">

This parent window would open a pop-up window, where it would allow the users to make their own selections. Upon clicking submit in this pop-up window, it would assign the selection to myField in the parent window and then the pop-up window would close.

All these are working fine. I put a temporary link on the parent window that would display the value of myField. Upon the closing of the pop-up window, I clicked this link and it showed the correct values.

My problem is, I have the following codes in the parent window,

  $('#myField').change(function(e) {
    alert("changed!!!");
  });

The alert box would never display, which means that the change event is not called in the parent window. So, my question is, is it possible to capture the change event on myField in the parent window?

Thanks in advance, Monte

+1  A: 

try this: trigger

$('selector for parent window')
    .find('#myField')
        .val('new value')
        .trigger('change');
andres descalzo
Thank you very much! The trigger part is what I am missing.
Monte Chan
A: 

You will need to use live

$('#myField').live("change", function() {
alert("changed!!!");
})
Liam Bailey
This does not work for me.
Monte Chan
try replacing .live with .bind
Liam Bailey