开发者

Issue with jquery popup window

开发者 https://www.devze.com 2022-12-20 17:50 出处:网络
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 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>
<开发者_Go百科/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


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({ ... });
});


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号