Your way doesn't work, mine does (or at least, should; I haven't
explicitly tested it).

Performance wise there is no issue to worry about.

Jörn

On Fri, Aug 21, 2009 at 10:10 AM, Jaggi<[email protected]> wrote:
>
> just so i'm understanding stuff right. Whats the difference between
> your way and my way and how much difference does it make on resources.
> I'm guess your saying i should do it this way:
>
>
>        $('#endDate').datepicker({
>                dateFormat: 'dd-mm-yy',
>                beforeShow: function(){
>                        $(this).datepicker("option", { minDate: 
> $('#startDate').datepicker
> ('getDate'),
>                                                                               
>     maxDate: $('#startDate').datepicker('getDate') });
>                }
>        }).attr('readonly', 'readonly');
>
> doesn't this way use more resources as i have to make an extra call to
> $(this)?
>
>
> On Aug 20, 8:00 pm, Jörn Zaefferer <[email protected]>
> wrote:
>> Put the code I mentioned inside the beforeShow callback!
>>
>> Jörn
>>
>> On Thu, Aug 20, 2009 at 5:53 PM, Jaggi<[email protected]> wrote:
>>
>> > the reason i use beforeShow is because doing it your way sets it when
>> > the page loads, now my users will come in and pick a start date and
>> > they could change this an infinite amount of times and i need the end
>> > date to reflect that each time. I believe your way only initializes it
>> > once. Thanks for the reply regarding the maxDate, looks like i'll have
>> > to do it the hard way then. Maybe something to add to the next version
>> > of jquery :).
>>
>> > On Aug 20, 3:11 pm, Jörn Zaefferer <[email protected]>
>> > wrote:
>> >> The main problem here is that the datepicker doesn't, or only barely,
>> >> expose its date-parsing abilities. So for that to work, you have to
>> >> get the date, transform it into something where you can add two
>> >> months, transform it back into something the datepicker understands,
>> >> and set that as the maxDate.
>>
>> >> Or your usage of beforeShow is rubbish. Instead of returning something
>> >> which gets ignored by the datepicker, you actually need to set these
>> >> options: $(this).datepicker("option", { minDate: ..., maxDate: ... });
>>
>> >> Jörn
>>
>> >> On Thu, Aug 20, 2009 at 1:43 PM, Jaggi<[email protected]> wrote:
>>
>> >> > I have two fields a start date and end date. What i've done is set the
>> >> > minDate of start date to today and then i set the minDate of end date
>> >> > to whatever startDate is set to. This all works fine. The issue is
>> >> > with setting maxDate of end date. I want to set it to 2months in the
>> >> > future of whatever the minDate is set to (so basically 2months ahead
>> >> > of the start date). Everything i've tried to do this has resulted in
>> >> > random results mostly in disabling any selecting of the date.
>>
>> >> > [code]
>> >> >        $('#endDate').datepicker({
>> >> >                dateFormat: 'dd-mm-yy',
>> >> >                beforeShow: function(){
>> >> >                        return{ minDate: 
>> >> > $('#startDate').datepicker('getDate'),
>> >> >                                        maxDate: 
>> >> > $('#startDate').datepicker('getDate') + '+2m'}
>> >> >                }
>> >> >        }).attr('readonly', 'readonly');
>> >> > [/code]
>>
>> >> > this is an example of my code, the maxDate setting doesn't work but
>> >> > thought i'd just give an example.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to