Posts

Showing posts from September, 2013

Cloning form elements in Internet Explorer

So, I ran into an issue when cloning form elements. The scenario was as follows: For an insurance company, a customer was reporting that a damage had occurred to one or more insured items. After adding general information about the event (it happened at such and such a date, while riding a bicycle), the customer added multiple items of goods that was damaged during the event. As a part of the damage goods part of the form, was a dropdown: Report a damage Date: What happened? What was damaged? A brand new Apple computer ... + Add item The idea was, that clicking the button would duplicate a part of the form, which would effectively increase the collection of block items in the associated view model: public class ReportViewModel { public List<BlockViewModel> Blocks { get; set; } } public class BlockViewModel { public string Title { get; set; } public List<QuestionViewModel> Questions { get; set; } } The solution worked pretty flawlessly too! For completeness

Multiple date formats in jQuery UI's datepicker

jQuery UI's datepicker supports one public format and, optionally, one internal one . However, if you're wanting to support multiple public formats, you're out of luck. In my scenario, I wanted to support yy-mm-dd (yyyy-MM-dd in .NET Date Formatting lingo ) yymmdd (yyyyMMdd) Having the top-most rule in effect, entering a date like 20130901 (September 1st, 2013) would make the datepicker change my value to today's date in the specified formatting, which was not what I wanted. To fix the issue, I set the least-restrictive format (yy-mm-dd) as the dateFormat: ... and added a keydown event listener to the DOM element I attached my datepicker to, so that it would hide the datepicker as the user started to enter input: With these two modifications in place, my datepicker now supported my two date formats for manual entry, while maintaining its click functionality, formatting any clicked date as configured in dateFormat. I hope this'll save you some time,