如何使用UiHint和jQuery函数对于多个输入?

时间:2016-02-18 09:10:39

标签: jquery asp.net-mvc-uihint

我有一个名为mymodel的模型并包含此

public class MyModel
{
    public int id { get; set; }
    public string name{get;set;}
    [UIHint("_ViewDate")]

    public string date { get; set; }
}

数据视图页面:

  @section scripts
    {

                <script src="~/Scripts/jquery-2.1.4.js" type="text/javascript"></script>
                <script src="~/Scripts/bootstrap.min.js" type="text/javascript"></script>

                <script src="~/Scripts/MdBootstrapPersianDateTimePicker/jalaali.js" type="text/javascript"></script>

                <script src="~/Scripts/MdBootstrapPersianDateTimePicker/jquery.Bootstrap-PersianDateTimePicker.js" type="text/javascript"></script>




    <script type="text/javascript">
        $('#txt').MdPersianDateTimePicker({
            Placement: 'bottom', // default is 'bottom'
            Trigger: 'focus', // default is 'focus',
            EnableTimePicker: true, // default is true,
            TargetSelector: '', // default is empty,
            GroupId: '', // default is empty,
            ToDate: false, // default is false,
            FromDate: false, // default is false,
        });
    </script>
    }
  @section head
    {
        <meta charset="utf-8" />

        <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
        <link href="~/Content/bootstrap-theme.min.css" rel="stylesheet" />
        <link href="~/Content/jquery.Bootstrap-PersianDateTimePicker.css" rel="stylesheet" />
    }
<dt>
    @Html.DisplayNameFor(model => model.date)
</dt>

<dd>
    @Html.DisplayFor(model => model.date)
</dd>
<dd>
    @Html.DisplayFor(model => model.date)

</dd>
<dd>
    @Html.DisplayFor(model => model.date)

</dd>

和_ViewDate由UIHint调用的部分视图

    <script type="text/javascript">
        $('#txt').MdPersianDateTimePicker({
            Placement: 'bottom', // default is 'bottom'
            Trigger: 'focus', // default is 'focus',
            EnableTimePicker: true, // default is true,
            TargetSelector: '', // default is empty,
            GroupId: '', // default is empty,
            ToDate: false, // default is false,
            FromDate: false, // default is false,
        });
    </script>
@model  string


<div class="form-actions">
    <input type="text" placeholder="Date..." class="text-primary" id="txt" />

</div>

    

现在,问题是当加载日期视图页面时我的操作只针对一个对象执行而没有再次执行。

0 个答案:

没有答案