views:

370

answers:

2

Hi,

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

A: 

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
I already tested this in other browser , same issue occurs.
Yashwant Chavan
+1  A: 

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({ ... });
});
Jesse Millikan
Jesse i am using same plugin to open my other popups its working fine.
Yashwant Chavan
I also confirm popupWindow library loaded properly
Yashwant Chavan
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
Ah, see http://stackoverflow.com/questions/815074/jquery-doesnt-see-new-elements which may be related.
Jesse Millikan
Hey Jesse its working ... thanks
Yashwant Chavan