2

I am using a popup plugin to open my popup window.

Generating html table using Javascript. In that there column Employee Id having hyperlink. I am openning popup on click of hyperlink to display the employee details.

Dynamic generated code:

<a id='" + arrElement[0].EMP_DATA[i].EMP_ID +"'
   href='employee.do?requestSource=EMP_PROFILE&empId=" + 
         arrElement[0].EMP_DATA[i].EMP_ID+"'
   class='empName' >
  <B>" +arrElement[0].EMP_DATA[i].EMP_NAME+"</B>
</a>

Issue: popup is open in the same window. This issue happen only when code is generated dynamically using java script

Following is my code to open the popup, calling script code after completion of employee table:

$('.empName').popupWindow({
  centerScreen: 1,
  scrollbars: 1,
  height: ($(window).height()-100),
  width: ($(window).width()-100)
}); 

Please help

Vicky
  • 9,515
  • 16
  • 71
  • 88

2 Answers2

1

First Try: The library might not be loading at all. Make sure that the javascript file that provides popupWindow is present and is being referenced correctly. Also, make sure that jquery itself is being loaded, since this library depends on it.

Try something like

alert($.fn.popupWindow);

after load to make sure that jQuery and the popupWindow library are loading. If that says something about a function reference or object, the problem is something else. Otherwise, jquery or the library isn't being loaded.

2nd Try:

See jquery doesn't see new elements, closely related question. jQuery doesn't recognize created elements 'immediately', you have to wait for the change to take place via events. It appears that you will want to use something like

$('.empName').change(function(){
  $('.empName').popupWindow({ ... });
});
Community
  • 1
  • 1
Jesse Millikan
  • 3,104
  • 1
  • 21
  • 32
  • Jesse i am using same plugin to open my other popups its working fine. – Vicky Feb 22 '10 at 11:17
  • I also confirm popupWindow library loaded properly – Vicky Feb 22 '10 at 11:24
  • Ah, another idea, are you making the popup window call in the same "event" as where you are writing the table? Try putting in a future event, e.g. using window.setTimeout(10, setupPopups); This could be because DOM elements are not immediately accessible after they're written... It's been too long since I messed with it to remember. – Jesse Millikan Feb 22 '10 at 12:03
  • Ah, see http://stackoverflow.com/questions/815074/jquery-doesnt-see-new-elements which may be related. – Jesse Millikan Feb 22 '10 at 12:14
0

Did you check it in another browser or on another system? It's probably a setting of your browser to open popups in a new tab in the same window (I'm assuming that's what happening, and that the popup doesn't replace your whole page).

Bart van Heukelom
  • 43,244
  • 59
  • 186
  • 301