javascript - How to properly set up datepicker attached to a button -


i working on django project using grappelli , trying create page mimics standard change form. page not based on model, adding in fields myself. however, having trouble using datepicker. whenever click button supposed show calendar, nothing happens. sure not including important.

here current code:

{% extends "admin/change_form.html" %}  {% block javascripts %} {{ block.super }} {% endblock %}  {% block content %}      <div id="grp-content-container">         <form enctype="multipart/form-data" action method="post">             {% csrf_token %}             <div>                 <fieldset class="module grp-module">                     <div class="form-row grp-row grp-cells-1 dob">                         <div class="field-box l-2c-fluid l-d-4">                             <div class="c-1">                                 <label class="required" for="dob">birthday</label>                             </div>                             <div class="c-2">                                 <p class="datetime">                                     <input class="vdatefield hasdatepicker" type="text" id="dob" name="dob">                                     <button id="dob-button" type="button" class="ui-datepicker-trigger"></button>                                 </p>                             </div>                         </div>                     </div>                </fieldset>             </div>         </form>     </div> {% endblock %} 

in javascripts block, had attempted add in datepicker source functionality taken website http://jqueryui.com/datepicker/, did not seem have effect. suggestions?

i've done before couple of times , want tell grappelli works out of box.

the point of interest:

grappelli.js lines:

var datefields = $("input[class*='vdatefield']:not([id*='__prefix__'])"); datefields.datepicker(options); 

and grappelli.reinitdatetimefields function reinits this.

so have put vdatefield or/and vtimefield class input field , make sure grappelli.js loaded , grappelli.initdateandtimepicker() being called when document ready. buttons datepicker should load automatically.

you can sure grappelli.initdateandtimepicker() being called other js-file: put debugger; somewhere in initdateandtimepicker constructor in grappelli.js , must pause in js-inspector.

hope that'll help, works me.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -