jquery datepicker onselect simple function -
the jquery datepicker plugin works, i'd have onselect triggering function opens page in new tab.
the jquery datepicker plugin works, i'd have onselect triggering function opens page in new tab.
$("#dp").datepicker({ beforeshowday: highlightdays, //works fine onselect: function(dates) { window.open('/en/calendar/' + dates, '_self'); }, }); var dates = [new date(2011, 4 - 1, 28), new date(2011, 5 - 1, 10),]; //does not work onselect: function(links) { window.open('/en/trip/' + links, '_self'); }, var links = [new link('link1'), new link('link2'),];
the js:
$( "#toggledp" ).click(function() { $("#dp ").datepicker('show'); }); $("#dp").datepicker({ changemonth: true, changeyear: true, showon: 'button', showbuttonpanel: true, buttonimageonly: true, buttonimage: "0.gif", dateformat: 'yy-mm-dd', beforeshowday: highlightdays, onselect: function(dates) { window.open('/en/calendar/' + dates, '_self'); }, }); var links =[new link('test'), new link('test1'), ]; var dates = [new date(2011, 4 - 1, 28), new date(2011, 5 - 1, 10), ]; var txt = ['test','test1',]; function highlightdays(date) { (var = 0; < dates.length; i++) { if (dates[i]-date==0) { return [true, 'markedday', txt[i],]; } } return [false, '']; }
if set onselect function(links) { window.open('/en/trips/' + links, '_self'); }, unknown reasons, opens url corresponding date not corresponding link.
here onselect handler syntax:
function(datetext, inst)
and explanation docs:
the function receives selected date text , datepicker instance parameters.
so when say:
onselect: function(links) { window.open('/en/trips/' + links, '_self'); }
so passing parameter links not array think inside handler context changed. i.e. links refers selected date mentioned above.
Comments
Post a Comment