jQuery UI datepicker options as varialbe
Posted
by
Desmond Liang
on Stack Overflow
See other posts from Stack Overflow
or by Desmond Liang
Published on 2011-01-06T03:29:22Z
Indexed on
2011/01/06
6:53 UTC
Read the original article
Hit count: 301
I have a number of inputs on a page function as JQ UI datepicker. Each needs to have different settings. I want to minimize the JS so I save the settings as an attribute in each individual .
<input type="text" class="datepicker" name="dateofbirth" id="dateofbirth" size="20" value="" options="{ dateFormat: 'yy-mm-dd',changeYear: true,yearRange: '1920:2010'}" />
<input type="text" class="datepicker" name="expdate" id="expdate" size="20" value="" options="{ yearRange: '2011:2020'}" />
I use js to load the options dynamically as the settings.
$(document).ready(function(){
$(".datepicker").each(function(index){
$(this).datepicker("option" , $(this).attr('options'));
});
});
datepicker is not functioning. If I empty the parentheses after $this.datepicker it works fine.
I have also tried another way to assign settings. ("option",...) no dice.
© Stack Overflow or respective owner