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

    
});

Link to comment
Share on other sites

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 ? 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • 1 month later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.