0

x-editable コントロールを使用しています。私のコードは次のとおりです。

<a href="#" id="status" runat="server" clientidmode="Static" 
data-url="/Handler/Save.ashx" data-type="select" data-pk="1" 
data-title="Status">Yes</a>

私のJavaScriptコード:

<script type="text/javascript">
    $(document).ready(function () {
        $.fn.editable.defaults.mode = 'popup';

        $('#status').editable({
            type: 'select',
            placement: 'right',
            value: 1,
            source:
            [
                { value: 1, text: 'Yes' },
                { value: 0, text: 'No' }
            ]
        });

    });
</script>

data-pk 値と新しい値を含むデータ /Handler/Save.ashx を送信するにはどうすればよいですか? また、ハンドラーを設定するにはどうすればよいですか?

ありがとう。

4

1 に答える 1

0

オーイエー。

まず、ハンドラWebMethod[()]の代わりに使用することをお勧めします。よりユーザーフレンドリーです;)。ashxWebMethod

[WebMethod()]
        public static string Save(string pk, string value)
        {
            string response = "";//TODO
            return response;
        }

そしてhtmlで:

<a href="#" data-type="select" class="editable"
            data-pk="1" data-source="{value: 1, text: 'Yes' },{ value: 0, text: 'No' }"
            data-value="1" data-url="/SomePage.aspx/Save" data-title="Select options"
            />

あなたのJavaScript:

<script type="text/javascript">
$(document).ready(function(){
    $('.editable' ).on('save', function (e, params){
        var x = params.response;
        //$('.bottom-right').notify({message: {text: x}}).show();
    });
});
</script>
于 2013-11-08T13:15:32.050 に答える