【问题标题】:Closing and opening two model pop-ups subsequently on a Button's Click event using JQuery随后使用 JQuery 在 Button 的 Click 事件上关闭和打开两个模型弹出窗口
【发布时间】:2011-06-28 08:42:42
【问题描述】:

我正在使用 JQuery 打开和关闭模型弹出窗口。

//Function to open pop-up

 function UserSignupModalpopupFromSubDomain(guid,title)
{
    var srcFile = "../ModelPopup/SignUpPopup.aspx"; 
 if (guid) srcFile += '?location=' + guid+'&title=' + title; /* sample code to append a unique user ID to page called */ 
    var cFrame = new Element('iframe').setProperties({id:"iframe-signup", name:"iframe-signup", height:'420px', width:'584px', frameborder:"0", scrolling:"no"}).injectInside(document.body);
 $('iframe-signup').src = srcFile;
 customModalBox.htmlBox('iframe-signup', '', 'Sign up'); 
 $('mb_contents_Popup').addClass('yt-Panel-Primary_Popup');
 new Element('div').setHTML(' ').setProperty('id','mb_Error_Popup').injectTop($('mb_center_Popup'));

 new Element('h2').setHTML('Sign UP').setProperty('id','mb_Title_Popup').injectTop($('mb_contents_Popup'));
//    $('mb_center').setStyle('z-index','2005');
//    $('mb_overlay').setStyle('z-index','2004');



      $('mb_center_Popup').setStyle('z-index','2005');
   $('mb_overlay_Popup').setStyle('z-index','2004');



}


// pop-up close function

function UserSignUpClose() {
 $('mb_close_link').addEvent('click', function() {
  //if($('yt-UserProfileContent1')) $('yt-UserProfileContent1').remove();
  if($('iframe-signup')) $('iframe-signup').remove();
  if($('mb_Title_Popup')) $('mb_Title').remove();
  if($('mb_contents_Popup')) $('mb_contents_Popup').removeClass('yt-Panel-Primary_Popup');
  if($('mb_Error_Popup')) $('mb_Error_Popup').remove();
  $('mb_overlay_Popup').setStyle('z-index','1600');
 });
}

当我们将关闭功能与弹出窗口的“取消”按钮一起使用时,它可以正常工作。

但我想关闭一个打开的弹出窗口并随后使用相同的链接按钮打开一个新的弹出窗口,为此我在 aspx.cs 页面的 Page_load 尝试如下:

lnkButton.Attribues.Add("onClick","UserSignUpClose();");
lnkButton.Attribues["onClick"]+="UserSignupModalpopupFromSubDomain(location.href,document.title);";

但它不起作用 当我尝试获取和使用它的 id 时,我无法获取它的属性,例如 id 和 type 以及 innerHTML。

先谢谢了。

【问题讨论】:

    标签: javascript jquery-ui django-models


    【解决方案1】:

    您正在分配 iframe-signupmb_Error_Popupmb_Title_Popup 作为元素的 ID,但您正在使用 $('iframe-signup').src = srcFile; 来选择元素 选择带有id的元素的jQuery语法如下

    $('#iframe-signup').src = srcFile;  // the # sign
    

    对所有此类选择执行相同操作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-20
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      相关资源
      最近更新 更多