简体   繁体   English

DataPicker jQuery不适用于MVC ASP.net中的@ Html.EditorFor

[英]DataPicker jQuery doesn't work with @Html.EditorFor in MVC ASP.net

I found jQuery DataPicker ( http://trentrichardson.com/examples/timepicker/#slider_examples ). 我找到了jQuery DataPicker( http://trentrichardson.com/examples/timepicker/#slider_examples )。

But it doesn't work with @HTML.EditorFor, why? 但这不适用于@ HTML.EditorFor,为什么?

@*working*@
<input type="text" name="basic_example_1" id="basic_example_1" value="">

@*not working*@
    @Html.EditorFor(model => model.eventstart, new { htmlAttributes = new { @class = "basic_example_1" } })

        <script>
        $('#basic_example_1').datetimepicker($.timepicker.regional['pl']);
    </script>

You are trying to access the 2nd example by id (#basic_example_1) while you give it a class. 在给第二个示例提供类的同时,您尝试通过其ID(#basic_example_1)访问第二个示例。 So trying using: 因此,尝试使用:

$('.basic_example_1').datetimepicker($.timepicker.regional['pl']);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM