user3304642
user3304642

Reputation: 191

Can't reset date picker

    <div id="menu">
    <div id="menuwrapper">
     <ul>
      <li id="m1" onclick="dates('from','to','2012-12-01','2012-12-31');">Mymenu1</li>
      <li id="m2" onclick="dates('from','to','2011-12-01','2011-12-31');">Mymenu2</li>
    </ul>
    </div>
   </div>

Here onclick I am calling javascript dates() which creates data widget where first 2 arguments from and to are division id, and argument 3 and 4 are ranges.

But problem is simultaneously both won't work for example if I clicked on Mymenu1, it shows datepicker with date range from '2012-12-01','2012-12-31' and now if I click on Mymenu2 it again shows same date range showed before here I expect '2011-12-01','2011-12-31'.

Is there any way to overcome from this problem ? I am creating menu dynamically in php with the help of this tutorial http://www.phpro.org/tutorials/Dynamically-Create-Menu-With-PHP-DOM.html.

Please guys help me, I guess I have to update from and to id after dates function is called but I don't know how to achieve this without reloading complete index.php, I Hope my problem is clear.

Have a nice day..

See result http://jsfiddle.net/VTvKJ/

Upvotes: 0

Views: 145

Answers (1)

user753676
user753676

Reputation:

You have to use $("selector").datapicker("destroy");

http://jsfiddle.net/fNYy6/

function dates(from,to,start,end){
    $("#"+from).datepicker("destroy");
    $("#"+to).datepicker("destroy");
    $("#" +from).datepicker({
...

I think you want this? http://jsfiddle.net/fNYy6/1/

I have fixed the minDate for the second datepicker

Upvotes: 1

Related Questions