更新面板和模态窗口 [英] update panel and modal windows

查看:179
本文介绍了更新面板和模态窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的mainpage.aspx然后我mainDetails.ascx

\r
\r

/ *除了这个JavaScript:* /\r
$(文件)。就绪(函数(){\r
  $(#模式 - 关闭)。点击(函数(){\r
    $(#模式内容,#模态背景,#模式 - 关闭)toggleClass(活动)。\r
  });\r
  $(#keywordSelection)。点击(函数(){\r
    警报('打');\r
  });\r
});\r
/*mainDetails.ascx是`ASP:UpdatePanel`这包含以下的javascript:* /\r
功能jsModal(){\r
  $(#keywordSearch)。点击(函数(){\r
    //警报('你好');\r
    $(#模式内容,#模态背景,#模式 - 关闭)toggleClass(活动)。\r
    //$(\"#modal-content\").$(\"divTestVal\").append.html\r
\r
    。VAR HTML = $(#模式内容),下一个(#divTestVal)HTML();\r
    警报(HTML);\r
  });\r
}

\r

< - mainpage.aspx是包含以下内容的Web表单! - >\r
&所述; SCRIPT SRC =htt​​ps://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js>&下; /脚本>\r
\r
< D​​IV ID =模式背景>< / DIV>\r
< D​​IV ID =模式内容>\r
  <输入类型=按钮ID =模式 - 关闭VALUE =关闭模态窗口/>\r
  < BR />\r
  < D​​IV ID =divTestVal>\r
    [附加价值在这里!]\r
  < / DIV>\r
  < BR />\r
  <输入类型=按钮ID =keywordSelection值=选择! />\r
< / DIV>

\r

\r
\r

我需要的是填充和模态读取的值的方式。现在的HTML变量返回

如何一个获得 [附加价值在这里!] 从模态值?


解决方案

我发现这样做的一种方式。

在mainDetail.ascx的JavaScript我增加了以下内容:

  $('#模式内容的div)。每个(函数(指数){
            警报($(本)的.text());
            $(本)。html的(现已更新文字);
        });

不仅通过对mainpage.aspx模态窗口,每个div这个循环中,但它在格也更新文本值。

I have my mainpage.aspx and then my mainDetails.ascx

/*As well as this javascript:*/
$(document).ready(function() {
  $("#modal-close").click(function() {
    $("#modal-content, #modal-background, #modal-close").toggleClass("active");
  });
  $("#keywordSelection").click(function() {
    alert('hit');
  });
});
/*mainDetails.ascx is an `asp:UpdatePanel` this contains the following javascript:*/
function jsModal() {
  $("#keywordSearch").click(function() {
    //alert('hi');
    $("#modal-content, #modal-background, #modal-close").toggleClass("active");
    //$("#modal-content").$("divTestVal").append.html

    var html = $("#modal-content").next("#divTestVal").html();
    alert(html);
  });
}

<!-- mainpage.aspx is a web form that contains the following:-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div id="modal-background"></div>
<div id="modal-content">
  <input type="button" id="modal-close" value="Close Modal Window" />
  <br />
  <div id="divTestVal">
    [Append Values Here!]
  </div>
  <br />
  <input type="button" id="keywordSelection" value="Selector!" />
</div>

What I need is a way to populate and read the values from the modal. Right now the html variable is returning null.

How do a get the [Append Values Here!] value from the modal?

解决方案

I found out a way of doing it.

in the mainDetail.ascx javascript I added the following:

        $('#modal-content div').each(function (index) {
            alert($(this).text());
            $(this).html("updated text now");
        });

Not only does this loop through each div in the modal window on the mainpage.aspx, but it also updates the text values in the div.

这篇关于更新面板和模态窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆