Jump to content

jQuery Datepicker DOM


Matrixkid

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/186814-jquery-datepicker-dom/
Share on other sites

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');
    });

    
});

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 ? 

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!

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.