Ben Pearce
Ben Pearce

Reputation: 7094

Dynamically Setting Max date in jQuery Mobile datebox

I"m having a heck of a time setting the date for the jQuery Mobile Datebox. I am able to set the end date to "2013-02-14" by setting the "max" attribute in the html tag

<input style="color:black" id="date-picker" min="2013-01-24" max="2013-02-14" name="defcal" type="date" data-role="datebox" value=""  id="defcal" data-options='{"mode": "calbox","calTodayButton": true}'/>

However if I try to set this attribute programmatically with a selector it doesn't work (refreshing the datebox doesn't seem to help).

I read through the approach linked below which seems extremely convoluted and I wasn't able to implement. Can any one suggest a simple way to do this.

http://dev.jtsage.com/jQM-DateBox2/demos/script/maxdays.html

Upvotes: 1

Views: 2093

Answers (1)

J.T.Sage
J.T.Sage

Reputation: 1984

You can now (as of about 10min ago) set min/max attributes then call:

$('element').datebox('applyMinMax');

to have datebox do all the math for you. I'd love to have it auto-catch this, but I'm not aware of a way to do this.

Upvotes: 3

Related Questions