laravel using twitter bootstrap and datepicker

不想你离开。 提交于 2019-12-13 05:04:11

问题


I am trying to render a datepicker in the form created by laravel tags. So far, nothing else is showing except a regular text field.

I've used this for the datepicker. And I did the below in the form:

<p>{{ Form::text('dob', '', array('class' => 'form-control','placeholder' => 'تاريخ الميلاد', 'data-datepicker' => 'datepicker')) }}</p>

Nonetheless, I am only getting this:

What is the recommendation here? I also added the css and js to the header so all should be in place.

Thanks,

Update: calling datepicker js function in the footer.blade.php where all other calls are:

{{ HTML::script('/public/assets/js/bootstrap-typeahead.js') }}
{{ HTML::script('/public/assets/js/bootstrap-datepicker.js') }}

<script>
    $('.datepicker').datepicker()
</script>

This still didn't change anything.


回答1:


Use an id to initialize the datepicker

{!! Form::input('date', 'dob', date('d-m-Y'), ['class' => 'form-control', 'id' => 'dob', 'data-date-format' => "dd-mm-yyyy"]) !!}

and use this javascript

$('#dob').datepicker();


来源:https://stackoverflow.com/questions/24609750/laravel-using-twitter-bootstrap-and-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!