Nerian/bootstrap-datepicker-rails

data-date-viewmode not working correctly?

exocode opened this issue · 3 comments

Could it be, that:

data-date-viewmode="years"

does not work correctly?

It stays on the day viewmode and not on the viewmode years

<label for="user_birthday">Birthday</label>
<div class="input-append date" id="user_birthday" data-date-viewmode="years" data-date-format="dd-mm-yyyy">
    <%= f.input_field :birthday, id: "user-birthday", class: "span2", :placeholder => 'dd-mm-yyyy' %>
    <span class="add-on" >
        <i style="color: grey;" class="icon-calendar"></i>
    </span>
</div>
<p class="help-block">Format must be dd-mm-yyyy</p>

html rendered

<div class="input-append date" id="user_birthday" data-date-viewmode="years" data-date-format="dd-mm-yyyy
    <input class="string required span2" id="user-birthday" name="user[birthday]" placeholder="dd-mm-yyyy" size="50" type="text" />
    <span class="add-on">
        <i style="color: grey;" class="icon-calendar"></i>
    </span>
</div>


<label for="user_birthday">Birthday</label>
<div class="input-append date" id="user_birthday" data-date-viewmode="years" data-date-format="dd-mm-yyyy">
    <%= f.input_field :birthday, id: "user-birthday", class: "span2", :placeholder => 'dd-mm-yyyy' %>
    <span class="add-on" >
        <i style="color: grey;" class="icon-calendar"></i>
    </span>
</div>
<p class="help-block">Format must be dd-mm-yyyy</p>

The guys from simple_form-bootstrap said, that this problem should be on bootstrap-datepicker-rails

heartcombo/simple_form-bootstrap#21 (comment)

Hi,

I don't see any data-date-viewmode option here: https://github.com/eternicode/bootstrap-datepicker

I think this is what you are looking for: https://github.com/eternicode/bootstrap-datepicker#startview

cool Nerian, thanks that worked:

<script type="text/javascript">
        $(document).ready(function () {
            $('#user_birthday').datepicker({startView: "decade" });
        })
</script>