1

jQueryについて質問です。

成功後にクリックイベントを作成する ajax 関数があります。

      var rowdiv = '#DiamondSetting';
        $(rowdiv).hide();
        $.ajax({

            type: "post",
            url: TabURL,
            data: "",

            beforeSend: function () {
                $(rowdiv).html('<table width="100%" border="0" cellpadding="3" cellspacing="0"><tr><td align="center"><img src="../Content/images/loading_row.gif" alt="updating" /><td></tr></table>');
            }, //show loading just when link is clicked 
            complete: function () {
                //$(updatediv).html("rejected");
            }, //stop showing loading when the process is complete 
            success: function (html) { //so, if data is retrieved, store it in html 
                //$(updatediv).html(html); //show the html inside .content div
                $(rowdiv).hide();
                $(rowdiv).fadeIn("slow");
                $(rowdiv).html(html);
                //select a particular metal after post back 
                $('input[id=metal0]').prop('checked', true).triggerHandler('click');
                $("#metal0").attr("disabled", true);

                $("#Romantic").bind('click');
            }
        });

ご覧のとおり、成功後:

私が欲しいのは、id="Romantic" の li 内のリンクをクリックすると、id="metal0" のチェックボックスがオンになり、無効になります..

しかし、それは id="Romantic" をトリガーしませんでした..

ページに移動するたびに、id="metal0" のチェックボックスがオンになり、無効になります。

そのため、ページをリロードしても、jQuery は引き続きトリガーされます。

ページをリロードした後に jQuery をトリガーして削除するにはどうすればよいですか?

君たちありがとう.. ;)

4

1 に答える 1

2

ページの ID は一意です。

したがって、これ は次$('input[id=metal0]')のように記述できます。$('#metal0')

次にdisabledプロパティを設定しても、イベントが発生しないわけではありません..offメソッドを探しています

$("#metal0").off("click"); // This will unbind the event handler
                           // if you attached the event using on

この行は意味がありません

$("#Romantic").bind('click');

イベントをバインドしているようですが、それに関連付けられているクリック ハンドラーはありません。

于 2013-06-21T02:48:19.550 に答える