3 ms·
$('[data-behavior~=date_picker]').live 'focus', -> $(this).datepicker() So basically every focus on the element creates a new datepicker. If you're not care
by radagaisus 14y ago
$('[data-behavior~=date_picker]').live 'focus', ->
$(this).datepicker()
So basically every focus on the element creates a new datepicker. If you're not careful this could mean memory bloat and unpredictable behavior as the plugin is attached several times.
- sim0n 14y agoI'm guessing their datepicker() function checks if the datepicker has already been attached or not. By using onfocus rather than attaching it on page load, the datepicker isn't loaded until it's required (gives a minor speed improvement I imagine).