javascript - Eternicode bootstrap datepicker: how do you pass options when you are using show event? -


i using https://stackoverflow.com/a/20719037/3255963 eternicode's datepicker pop when calendar icon selected opposed default behavior pops on field focus.

    $('.input-group-addon').click(function () {         $('.input-group.date').datepicker('show');     }); 

how add options autoclose code?

<form class="myform" method="get" action="servlet" class="navbar-form navbar-left">    <div class="col-md-3">       <div class="input-group date">       <input id="datepicker" name="pickeddate" type="text" class="form-control" placeholder="mm/dd/yyyy"/><span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>       </div>    </div>    <button type="submit" class="btn btn-success"><i class="glyphicon glyphicon-ok"></i> calculate dates!</button> <button type="reset" class="btn btn-warning"><i class="glyphicon glyphicon-remove"></i> reset</button>    <input id="month" name="monthhtml" value="" type="hidden"/>    <input id="day" name="dayhtml" value="" type="hidden"/>    <input id="year" name="yearhtml" value="" type="hidden"/> </form> 

you need create datepicker in advance.

so if have html:

<div class="input-group">    <input type="text" class="form-control" id="datetext"/>    <span class="input-group-btn">      <button class="btn btn-default" type="button" id="datebtn">         <span class="glyphicon glyphicon-calendar"></span>      </button>    </span> </div> 

then following javascript work, options passed datepicker when initialized:

$('#datetext').datepicker({    autoclose: true,                                format: "dd mm yyyy"                           })               .off('focus'); $('#datebtn').click(function () {     $('#datetext').datepicker('show'); }); 

js fiddle here.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -