1

次のコードを使用して、HTML入力の変更テキストをキャプチャしています。

$(document).ready(function() {
    $(':input', document.myForm).bind("change", function() { setConfirmUnload(true); }); 
});

これは、通常のテキストボックスとチェックボックスで正常に機能します。

入力タグをレンダリングするTelerikのMVCComboBoxForを使用していますが、上記のJQueryをトリガーしていないようです。

これをキャプチャする方法はありますか?

HTMLのレンダリング方法は次のとおりです。

<div class="t-widget t-combobox t-header" id="InterviewRequired">
<div class="t-dropdown-wrap t-state-default">
    <input class="t-input" id="InterviewRequired-input" name="InterviewRequired-input" title="InterviewRequired" type="text" value="Select" />
    <span class="t-select t-header">
        <span class="t-icon t-arrow-down">select</span>
    </span>
</div>
<input id="InterviewRequired-value" name="InterviewRequired" style="display:none" type="text" value="0" />

ここで回答が得られない場合に備えて、 Telerikフォーラムでもこの質問をしました。

4

2 に答える 2

5

アタッチできるイベントのリストは次のとおりです: http://www.telerik.com/community/forums/aspnet-mvc/combobox/jquery-event-names.aspx

JavaScript を使用してより動的な方法で変更イベントをアタッチする場合は、「change」ではなく「valueChange」イベントにアタッチします。

$(document).ready(function() {
    $('#ComboBoxId').bind("valueChange", function() { setConfirmUnload(true); }); 
});
于 2012-04-03T19:23:22.047 に答える
2

ここでデモを見る。<input/>ComboBox はポップアップとしてレンダリングされています<div/>

<div class="t-dropdown-wrap t-state-default">
  <input type="text" value="Chai" name="ComboBox-input" id="ComboBox-input" class="t-input" autocomplete="off">
  <span class="t-select t-header">
    <span class="t-icon t-arrow-down">select</span>
  </span>
</div>

クライアント側のドキュメントを見ると、おそらくここにあるクライアント側のイベントを登録する必要があります

   <%= Html.Telerik().ComboBox()
            .Name("ComboBox")
            .ClientEvents(events => events
                .OnChange("onChange")
            )
    %>

    <script type="text/javascript">
        function onChange(e) {
           setConfirmUnload(true);
        }
    </script>

また、この例からのみ jQuery で実行できるように見えます。

<%= Html.Telerik().ComboBox().Name("ComboBox") %>

<script type="text/javascript">
    $(document).ready(function() {
        $('#ComboBox').bind('change', function(e) { // your code });
    });
</script>

多分試してください:

$(document).ready(function() {
    $('#myComboBox').bind("change", function() { setConfirmUnload(true); }); 
});
于 2011-03-17T11:51:19.377 に答える