0

キャッシュされた値を使用してユーザーに表示する MVC ビューがあります

@Html.TextboxFor(x => x.SomeInteger, new { @class="selector" });

および同様の構造。

私の問題は、私がこれを行うときです

$(“.selector”).wijinputnumber({
    type: ‘numeric’,
    minValue: 0,
    decimalPlaces: 0,
    showSpinner: true
});

テキストボックスの値は 0 に設定されますが、(たとえば) ユーザーが以前に 4 を入力した可能性があるため、それを反映する必要があります。また、モデルの SomeInteger プロパティに実際に 4 があることを確認したので、そうではありません。

wijinputnumber に初期値を設定しないように指示する方法はありますか?

この問題を示す HTML と Wijmo/jQuery のみの完全な例を次に示します。

<!DOCTYPE HTML>
<html>
<head>
    <link href="http://cdn.wijmo.com/themes/rocket/jquery-wijmo.css" rel="stylesheet" type="text/css" />
    <link href="http://cdn.wijmo.com/jquery.wijmo-open.1.1.2.css" rel="stylesheet" type="text/css" />
    <link href="http://cdn.wijmo.com/jquery.wijmo-complete.1.1.2.css" rel="stylesheet" type="text/css" />
    <script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.min.js" type="text/javascript"></script>
    <script src="http://cdn.wijmo.com/external/jquery.bgiframe-2.1.3-pre.js" type="text/javascript"></script>
    <script src="http://cdn.wijmo.com/external/jquery.glob.min.js" type="text/javascript"></script>
    <script src="http://cdn.wijmo.com/external/jquery.mousewheel.min.js" type="text/javascript"></script>
    <script src="http://cdn.wijmo.com/external/raphael-min.js" type="text/javascript"></script>
    <script src="http://cdn.wijmo.com/jquery.wijmo-open.1.1.2.min.js" type="text/javascript"></script>
    <script src="http://cdn.wijmo.com/jquery.wijmo-complete.1.1.2.min.js" type="text/javascript"></script>
</head>
<body>  
    <input type="text" class="correct" value="5" />

    <input type="text" class="notcorrect" value="10" /> 

    <script type="text/javascript">
        jQuery(document).ready(function($) {
            $('.correct').wijtextbox();         

            $(".notcorrect").wijinputnumber({
            type: 'currency',
            decimalPlaces: 2,
            showGroup: true,
            showSpinner: true
            });             
        });
    </script>
</body>
</html>
4

2 に答える 2

1

要素でval()関数を使用して、その値を取得できます

<script type="text/javascript">
    jQuery(document).ready(function($) {
        $('.correct').wijtextbox();         

        $(".notcorrect").wijinputnumber({
            type: 'currency',
            decimalPlaces: 2,
            showGroup: true,
            showSpinner: true,
            value: $(".notcorrect").val()
        });             
    });
</script>

お役に立てれば、

マット

于 2011-03-02T23:09:10.513 に答える
0

現在、これは Wijmo のバグであることが判明していますが、この投稿からの回避策は次のとおりです。

$(“.selector”).each(function () {
var n = $(this).val();
$(this).wijinputnumber(
{
type: ‘numeric’,
minValue: 0,
decimalPlaces: 0,
showSpinner: true,
value: n
});
});
于 2011-03-03T02:13:51.273 に答える