Matrixkid Posted December 31, 2009 Share Posted December 31, 2009 Hi there, Im running into an issue with the jquery ui datepicker plugin. I have it working and functioning correctly, but I need to change the way it operates. here is my current code: $("input.calendarSelectDate").live('click',function(){ $(this).datepicker({inline: true, showButtonPanel: true, buttonImage: '/cal.gif', buttonImageOnly: false, showButtonPanel: true, showOn:'both'}).datepicker('show'); }); the problem is is that the input field is loaded from an ajax call. and so the button doesnt appear next to the input box until the input field has been clicked. Is there a way to display the button before the click action is made? What about loading the the datepicker function with another event? Is there a way to bind it after the ajax call, so its almost like it runs on document.ready, with just $('#inputfield').datepicker(); - without the 'click' action binding it? Thanks for the help. MK Quote Link to comment https://forums.phpfreaks.com/topic/186814-jquery-datepicker-dom/ Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2009 Share Posted December 31, 2009 you should do something like this $(document).ready(function() { $("input.calendarSelectDate").datepicker({inline: true, showButtonPanel: true, buttonImage: '/cal.gif', buttonImageOnly: false, showButtonPanel: true, showOn:'both'}); $("input.calendarSelectDate").click(function() { $(this).datepicker('show'); }); }); Quote Link to comment https://forums.phpfreaks.com/topic/186814-jquery-datepicker-dom/#findComment-986514 Share on other sites More sharing options...
Matrixkid Posted December 31, 2009 Author Share Posted December 31, 2009 Hey Rajiv, That didnt work. The element, input.calendarSelectDate doesnt exist upon page load, and therefore is bound to nothing. It only exists upon an ajax request. I hope that helps clarify it. Thanks MK Quote Link to comment https://forums.phpfreaks.com/topic/186814-jquery-datepicker-dom/#findComment-986517 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2009 Share Posted December 31, 2009 you could put the initialization of the datepicker in your ajax call function, because currently the live function of jquery only supports click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup events, you could retain the show in the live click, also your ajax call has a callback function which you could use, which function are you using for the ajax call ? Quote Link to comment https://forums.phpfreaks.com/topic/186814-jquery-datepicker-dom/#findComment-986519 Share on other sites More sharing options...
Matrixkid Posted December 31, 2009 Author Share Posted December 31, 2009 you could put the initialization of the datepicker in your ajax call function, because currently the live function of jquery only supports click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup events, you could retain the show in the live click, also your ajax call has a callback function which you could use, which function are you using for the ajax call ? Im currently using load to make the request. I believe load has callback functionality. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/186814-jquery-datepicker-dom/#findComment-986522 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2009 Share Posted December 31, 2009 yes you could just put it in your call back functionality load( url, [data], function() {[put the initialization of the datepicker here]} ) Quote Link to comment https://forums.phpfreaks.com/topic/186814-jquery-datepicker-dom/#findComment-986526 Share on other sites More sharing options...
Matrixkid Posted December 31, 2009 Author Share Posted December 31, 2009 yes you could just put it in your call back functionality load( url, [data], function() {[put the initialization of the datepicker here]} ) Perfect. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/186814-jquery-datepicker-dom/#findComment-986530 Share on other sites More sharing options...
amakrid Posted February 11, 2010 Share Posted February 11, 2010 yes you could just put it in your call back functionality load( url, [data], function() {[put the initialization of the datepicker here]} ) So many thanks for your answer !!!!!!!!!!!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/186814-jquery-datepicker-dom/#findComment-1011023 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.