[ 2 posts ]

Robert Hammonds

  • Username: RHammonds
  • Joined: Thu May 03, 2012 10:50 am
  • Posts: 1
  • Offline
  • Profile

Issues with creating a custom calendar module

Post Posted: Thu May 03, 2012 10:58 am
+0-
Good Afternoon,

I'm having some issues with a calendar module I am trying to create. I set up the event handlers to show and hide the calendar on specific events. However, when this.hide() is called nothing happens. I have confirmed that this.hide() is being called.

Here is the Module Code

Code:
YUI.add('calendar',function(Y){   
   function Calendar(config){
      Calendar.superclass.constructor.apply(this, arguments);
   }   
   Calendar.NAME="calendar";   
   Calendar.ATTRS={
         height:{value:"200px"},
         width:{value:"200px"},
         format:{value:"%x"},
         inputField:{value:"null"}         
   };   
   Y.extend(Calendar,Y.Calendar,{
      initializer: function(config) {                  
         var dateInputField = Y.one(this.get("inputField"));         
         dateInputField.on('focus',function(e){
            this.render();
            this.show();
         },this);         
      },   
      bindUI:function(){
         this.on('selectionChange',function(ev){      
            var newDate = ev.newSelection[0];
            var formattedDate = Y.DataType.Date.format(newDate,{format:this.get("format")});
            dateInputField.set('value',formattedDate);      
            this.hide();      
         },this);
         var dateInputField = Y.one(this.get("inputField"));
         dateInputField.on('clickoutside',function(e){               
            alert('in hide');
            this.hide();            
         },this);         
      }               
   });   
   Y.Calendar = Calendar;   
}, '1.0.0', {
   requires : [ 'calendar','event','datatype-date','node' ]
});



Any ideas would be great.

Thanks

Allen Rabinovich

YUI Developer

  • YUI Developer
  • Offline
  • Profile

Re: Issues with creating a custom calendar module

Post Posted: Tue May 08, 2012 9:54 pm
+0-
Are you actually using 'calendar' as the NAME of your extended module? The CSS class name used to hide the calendar is generated from the module name, and it is "yui3-{NAME property}-hidden". That class actually has an appropriate CSS attribute for hiding the DOM element. If your NAME is different, then you would have to make sure that yui3-yourname-hidden is defined in your CSS.

Another issue is overriding Calendar's bindUI (bindUI does not get chained on extend). bindUI contains essential logic and removing it will break your calendar. You'll want to do something like Y.after(this.bindUI, this, 'yourBindUI'); in the constructor, and then implement your own bindings in yourBindUI.

Hope this helps.
  [ 2 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
cron