jQuery的在更新面板没有成功面板刷新后加入的CssClass [英] jQuery in update panel not successfully adding cssclass after panel refresh

查看:178
本文介绍了jQuery的在更新面板没有成功面板刷新后加入的CssClass的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div,点击它时,会显示一个隐藏的asp:通过下面的jQuery文本框

I have a div, which when clicked, displays a hidden asp:textbox via the following jQuery.

      function BindEvents() {
          $(document).ready(function () {
             $("#showtextbox").click(function () {  
                 $("#TextBox1").removeClass("hidden"); 
                 $("#TextBox1").addClass("showInline");  
      });

这工作正常,但之后更新面板将被刷新。它是刷新后,点击showtextbox的时候,文本框保持隐藏。我知道,jQuery的运行,因为它是调试时命中。这里是我的code。

This works fine, except after the update panel is refreshed. After it is refreshed, when clicking "showtextbox" the textbox remains hidden. I know that the jQuery is running because it is hit when debugging. Here is my code.

  <ContentTemplate>
        <script type="text/javascript">
              Sys.Application.add_load(BindEvents);
        </script>
   </ContentTemplate>

   <asp:textbox runat="server" id="TextBox1"  CssClass="hidden" /> <span id="showtb8"/>

任何想法是怎么回事?如何使文本框可见更新面板刷新后?我认为这增加了Sys.Application.add_load后,它会工作,但事实并非如此。这也是一个向导控制如果有所作为。

Any ideas what’s going on here? How can I make the textbox visible after the update panel is refreshed? I thought that after adding it to the Sys.Application.add_load it would work, but it doesn't. This is also in a wizard control if that make a difference.

*我要指出,这个相同的逻辑显示和隐藏一个普通的div时工作正常。它只是不与ASP工作:文本

*I should note, that this same logic works fine when showing and hiding a regular div. It just is not working with the asp:textbox.

推荐答案

电话如果您使用常规绑定事件绑定丢失。
尝试的jQuery的功能。

after ajax calls the event bindings are lost if you use regular bindings. try the on function of jquery.

         $("#showtextbox").on('click',function () {  
             $("#TextBox1").removeClass("hidden"); 
             $("#TextBox1").addClass("showInline");  
          });

这篇关于jQuery的在更新面板没有成功面板刷新后加入的CssClass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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