2015-11-15 17 views
0

我发现jQuery DataPicker(http://trentrichardson.com/examples/timepicker/#slider_examples)。DataPicker jQuery不能在MVC中使用@ Html.EditorFor ASP.net

但它不能用@ 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> 

回答

1

您试图通过id(#basic_example_1)访问第二个示例,同时给它一个类。所以尝试使用:

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