[ 7 posts ]

mc_hendriks

  • Joined: Sat Apr 24, 2010 5:53 am
  • Posts: 43
  • Offline
  • Profile

using selected does not position calendar properly

Post Posted: Tue Sep 07, 2010 10:26 am
+0-
First of all I think this is a great module.

I have two questions:

1. When I use the selected option and the selected date is not in the current month than the calendar starts still in the current year/month. Is it possible to start the calendar in the selected date.

example from the example script:

//Popup calendar, click on the vacant space to close the calendar
new Y.Calendar('J_popup_closeable',{
selected:showdate(-20,new Date()),
popup:true,
closeable:true
}).on('select',function(d){
alert(d);
});

2. Is it possible to pre-format the returned date time function:
instead of using this:
new Y.Calendar('btn_calendar',{
selected:showdate(-20,new Date()),
closeable:true,
popup:true
}).on('select',function(d) {
alert(Y.DataType.Date.format(d, {format:"%Y-%m-%d %T"}));
});

new Y.Calendar('btn_start_datum',{
selected:new Date(Y.one('#start_datum').get('value')),
format:'%Y-%m-%d %T',
closeable:true,
popup:true
}).on('select',function(d) {
alert(d);
});


The second question is a nice to have. :)

Simon Gilligan

  • Username: sgilligan
  • Joined: Wed Jun 16, 2010 4:35 pm
  • Posts: 76
  • Location: Victoria, Australia
  • Offline
  • Profile

Re: using selected does not position calendar properly

Post Posted: Tue Sep 07, 2010 8:38 pm
+0-
re 1 - try calling the render method with your selected date. eg:

Code:
c = new Y.Calendar ...

c.render({selected:c.date})

mc_hendriks

  • Joined: Sat Apr 24, 2010 5:53 am
  • Posts: 43
  • Offline
  • Profile
Tags:

Re: using selected does not position calendar properly

Post Posted: Thu Sep 09, 2010 10:34 am
+0-
Unfortunately this doesn't solve it.

Perhaps something wrong in my code:

http://www.digirent.nl/psmyui/vb/cal1.html

Any clues?

Simon Gilligan

  • Username: sgilligan
  • Joined: Wed Jun 16, 2010 4:35 pm
  • Posts: 76
  • Location: Victoria, Australia
  • Offline
  • Profile

Re: using selected does not position calendar properly

Post Posted: Sun Sep 12, 2010 3:24 am
+0-
.. sorry .. forgot I had to do a bit more (this really should be in the code base)

I run with a local copy of the module, and inserted at line 190 a fire of the show event:

Code:
      that.EV[1] = Y.one('#'+that.id).on('click',function(e){
         e.halt();
         if(that.con.getStyle('visibility') === 'hidden'){
            that.EventCenter.fire("show");   // <-------- insert fire of show event
            that.show();
         }else{
            that.hide();
         }
      });


Then I coded to do the render, on show. eg:

Code:
       
   var c = new Y.Calendar('btn_start_datum',{
      selected:new Date(Y.one('#start_datum').get('value')),
      closeable:true,
      popup:true   
   });

   c.on('show', function() {
         c.render({selected:c.date})
   });
   
   c.on('select',function(d) {
         Y.one('#start_datum').set('value',Y.DataType.Date.format(d, {format:"%Y-%m-%d %T"}));   
   });



See if that helps ...

mc_hendriks

  • Joined: Sat Apr 24, 2010 5:53 am
  • Posts: 43
  • Offline
  • Profile

Re: using selected does not position calendar properly

Post Posted: Sun Sep 12, 2010 6:43 am
+0-
I figured the following out instead of using "selected" I had to use "date"


new Y.Calendar('J_popup_closeable',{
date:showdate(-20,new Date()),
popup:true,
closeable:true
}).on('select',function(d)

This renderes the calendar properly only when using the time fields these are not adjusted,

Simon Gilligan

  • Username: sgilligan
  • Joined: Wed Jun 16, 2010 4:35 pm
  • Posts: 76
  • Location: Victoria, Australia
  • Offline
  • Profile

Re: using selected does not position calendar properly

Post Posted: Sun Sep 12, 2010 4:08 pm
+0-
That may run into problems once the calendar is instantiated (from memory I think I tried that). ie, on your first calendar open it's fine, but manually change your input field, and then open the calendar again, and it may not render correctly (try it by varying the month so it takes the calendar out of it's current view).

mc_hendriks

  • Joined: Sat Apr 24, 2010 5:53 am
  • Posts: 43
  • Offline
  • Profile

Re: using selected does not position calendar properly

Post Posted: Fri Sep 17, 2010 8:36 am
+0-
Thanks for thinking with me. With the extra fire event in the gallery-calendar.js and the following with the selected instead of the date is working correctly:

var c = new Y.Calendar('btn_start_datum',{
selected:new Date(Y.one('#start_datum').get('value')),
closeable:true,
popup:true
});

c.on('show', function() {
c.render({selected:new Date(Y.one('#start_datum').get('value'))})
});

c.on('select',function(d) {
Y.one('#start_datum').set('value',Y.DataType.Date.format(d, {format:"%Y-%m-%d"}));
});

see also http://www.digirent.nl/psmyui/vb/cal1.html
  [ 7 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum