Custom DateTime field and repeating sections.

  • 9 November 2017
  • 2 replies
  • 3 views

Badge +4

Since SP's DateTime control does not allow me to let the user specify anything non-date I use a text box and a jquery calendar control and set the constraint to false.Then just apply the CSS where needed. It works good except for in a repeating section.

NWF$('.DATEFIELD input').attr("placeholder", "mm/dd/yyyy").datepicker({ constrainInput: false });

The problem exists after you add a row. The calendar pops up and you can click the date but it does not populate the field. The Placeholder exists. But no date is populated. If I save and exit and go to the next row it works only if the row exists, just not after I click add row.

Any ideas?

Thanks.


2 replies

Badge +4

Figured it out. I needed the RegisterRepeaterRowAdded event.

NWF.FormFiller.Events.RegisterAfterReady(function () {     NWF$('.DATEFIELD input').attr("placeholder", "mm/dd/yyyy").datepicker({ constrainInput: false });   
}
);

NWF.FormFiller.Events.RegisterRepeaterRowAdded(function (){

     var repeaterRow = NWF$(arguments[0][0]);
     
if(NWF$(repeaterRow.parents('.nf-repeater')[0]).hasClass('myrepclass'))      { 

                   NWF$('.DATEFIELD input').attr("placeholder", "mm/dd/yyyy").datepicker({ constrainInput: false });
         }
});

Thanks.

Badge

what is argument[0][0] ?

Reply