View Issue Details

This issue affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
08849Bug reportsSurvey editingpublic2014-03-13 18:50
Reportertpartner Assigned Tomfaber  
PrioritynormalSeveritypartial_block 
Status closedResolutionnot fixable 
Product Version2.05+ 
Summary08849: Setting custom options for datepicker no longer works
Description

You can no longer use JavaScript to dynamically set the datepicker options (minDate, maxDate, etc).

In previous versions this was possible by placing JS in the question source or template.js.

Steps To Reproduce

Create a date question and add the following script to the question source. This script should set the maxDate to todays date.

<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#question{QID} .popupdate').datepicker( 'option', 'maxDate', new Date() );
});
</script>

Additional Information

This is caused by the fact that these options are now set by the setPickerOptions() function every time the datepicker is shown. See https://github.com/LimeSurvey/LimeSurvey/commit/15d5587c939b17d641088ba374cd286e141ac48d.

TagsNo tags attached.
Bug heat4
Complete LimeSurvey version number (& build)fee21b2bb989967b363485a7085d
I will donate to the project if issue is resolvedNo
BrowserAll
Database type & versionN/A
Server OS (if known)Win 32
Webserver software & version (if known)Apache/2.4.3 (Win32)
PHP Version5.4.7
Git branch / Pull Request URL

Users monitoring this issue

There are no users monitoring this issue.

Activities

tpartner

tpartner

2014-03-13 15:03

partner   ~29239

Hi mfaber,

Why can't these options be set at initialization as in the past?

The problem here is that a script like above does actually work but then is overridden the next time the picker is displayed.

mfaber

mfaber

2014-03-13 16:28

reporter   ~29243

The datepicker needs to react dynamically to changes on the pages.
Imagine one date field is used as the minimum date for another field.
If the first field changes, the datepicker minimum needs to be (re-)set accordingly.

Does that make sense?

Apart from that, why use manual scripts and not the field in LS?

tpartner

tpartner

2014-03-13 16:52

partner   ~29244

I am concerned with backwards compatibility. The 2.05 comfort update has only been available for a couple of weeks and I am already getting clients complaining that their date questions no longer work.

mfaber

mfaber

2014-03-13 17:07

reporter   ~29245

I see the problem....on the other hand I think it's not feasible to guarantee users that custom JS which changes under-the-hood LS behaviour to work in future versions. This would mean we could never change anything structural.

And in this case there is a new feature which helps the same users that had to come up with custom js solutions before. I'm open for suggestions if there's a way to make both work at the same time but I would not like to sacrifice this feature for backward compatibility of workarounds.

tpartner

tpartner

2014-03-13 17:25

partner   ~29247

Err...I don't see these as "custom JS" or "workarounds", I see them as a perfectly valid extension of the included jQuery UI Datepicker. That is, after all, why there are settable options in the API.

Maybe we should add to the documentation that the jQuery UI options are no longer available.

mfaber

mfaber

2014-03-13 18:14

reporter   ~29249

For my colleagues (or other non-IT folks), pressing the "source button" and then entering something with a whole lot of brackets, braces and other funny stuff would be very hacky, geeky or custom. All a matter of perspective, I guess ;).

I have added a note in the manual (listed, as a matter of fact, under "Workarounds" http://manual.limesurvey.org/Workarounds:_Question_design,_layout_and_templating#Minimum_or_Maximum_Date_in_Datepicker).

tpartner

tpartner

2014-03-13 18:28

partner   ~29250

Thank you.

Issue History

Date Modified Username Field Change
2014-03-13 14:59 tpartner New Issue
2014-03-13 14:59 tpartner Status new => assigned
2014-03-13 14:59 tpartner Assigned To => mfaber
2014-03-13 15:03 tpartner Note Added: 29239
2014-03-13 16:28 mfaber Note Added: 29243
2014-03-13 16:52 tpartner Note Added: 29244
2014-03-13 17:07 mfaber Note Added: 29245
2014-03-13 17:25 tpartner Note Added: 29247
2014-03-13 18:14 mfaber Note Added: 29249
2014-03-13 18:28 tpartner Note Added: 29250
2014-03-13 18:50 mfaber Status assigned => closed
2014-03-13 18:50 mfaber Resolution open => not fixable
2019-11-01 17:25 c_schmitz Category Survey design => Survey editing