Created
November 14, 2018 22:46
-
-
Save jsmithdev/9c90fa7600880674412f623883bd69d7 to your computer and use it in GitHub Desktop.
Salesforce: Override datepicker, implement Pikaday
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Static Resource: https://drive.google.com/file/d/1yZMzQMYkNa40JyRTOoQvMMLZg_bL-1F9/view?usp=sharing --> | |
| <apex:page controller="Example"> | |
| <link rel="stylesheet" href="{!URLFOR($Resource.FormsResource, '/pikaday/css/pikaday.css')}" /> | |
| <apex:inputField styleClass="datepicks" value="{!Opp.StartDate}" /> | |
| <script src="{!URLFOR($Resource.FormsResource, 'currency.js')}" ></script> | |
| <script src="{!URLFOR($Resource.FormsResource, '/moment/moment.js')}" ></script> | |
| <script src="{!URLFOR($Resource.FormsResource, '/pikaday/pikaday.js')}" ></script> | |
| <script> | |
| //remove sf dates from ui then kill its function (already broken) and replace with pikaday datepicker | |
| Array.from(document.querySelectorAll('.dateFormat')).forEach(el => | |
| el.parentElement.removeChild(el) ) | |
| if(DatePicker == "function"){ | |
| DatePicker = () => console.log('using pikaday') | |
| } | |
| Array.from(document.querySelectorAll('.datepicks')).forEach(el => { | |
| new Pikaday({ | |
| field: el, | |
| format: 'M/D/YYYY' | |
| }) | |
| if(el.value){ | |
| el.value = moment(el.value).format('M/D/YYYY') | |
| } | |
| el.onfocus = () => {} | |
| }) | |
| </script> | |
| </apex:page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment