0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jQueryイベントがうまくいかない…

Last updated at Posted at 2015-09-17

事象

a-jaxのイベントの発生前までは動作するが
イベント後になんか動作しない

test.aspx

    <script type="text/javascript">
    <!--
        $(document).ready(function () {
            $('#TextBox').on('change', function () {
                //イベント発生!!
            });

        });

    //-->
    </script>    

    <td>
        <asp:HiddenField ID="HiddenField" runat="server" />
        <asp:TextBox ID="TextBox" runat="server" Width="200px" ReadOnly="true" />
        <asp:Button ID="Button001" runat="server" Text="※"  width="50px"/>
    </td>


もしかすると

いろいろいじってみると、発生するのは「Button」の時だけ
予想としては、何かa-jaxのイベント発行後に
該当のイベントの習得ができないのかなと…

一応これで動いた

UPDATEパネルか

test.sap
$(document).ready(function() {
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    // 開始時のイベント
    prm.add_beginRequest(function() {
       // 開始時のイベント記述
    });
    // 終了時のイベント
    prm.add_endRequest(function() {
        // 開始時のイベント記述
    });
});

上のサンプルに追記すると

test.aspx

    <script type="text/javascript">
    <!--
        $(document).ready(function () {
            //全体のアップデートパネルの設定
            var prm = Sys.WebForms.PageRequestManager.getInstance();

            // 終了時のイベントに設定する
            prm.add_endRequest(function () {
	            $('#TextBox').on('change', function () {
	                //イベント発生!!
	            });
            });

            $('#TextBox').on('change', function () {
                //イベント発生!!
            });


        });

    //-->
    </script>    

    <td>
        <asp:HiddenField ID="HiddenField" runat="server" />
        <asp:TextBox ID="TextBox" runat="server" Width="200px" ReadOnly="true" />
        <asp:Button ID="Button001" runat="server" Text="※"  width="50px"/>
    </td>


参考

[■UpdatePanelの更新をフックする - Architect Life]
(http://d.hatena.ne.jp/coma2n/20080718/1216362909)

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?