1

i have tow pages one is mange.aspx and other is pop-up.aspx in mange.aspx i load the other page with ajax and display it in jquery ui Dialog

my problem is when i load page the jquery ui Datepicker inside that page not working

this is my code

$(function () {
     $("#datepicker").datepicker({
         showOn: "button",
         buttonImage: "../images/calendar-icon.png",
         buttonImageOnly: true
     });

     $('#Add').click(function () {
         var $dialog = $('<div id="MyDialog"></div').appendTo('body')
      .load("../Pop-up.aspx #pop-up")
      .dialog({
         position: 'center',
         width: 550 
           // code .....
      });
   });
});

1 Answer 1

2

You need to create the datepicker after you load the popup. Creating the datepicker before will do nothing.

function createDatePicker() {
    $("#datepicker").datepicker({
        showOn: "button",
        buttonImage: "../images/calendar-icon.png",
        buttonImageOnly: true
    });
}

$(function () {
    $('#Add').click(function () {
        var $dialog = $('<div id="MyDialog"></div').appendTo('body')
          .load("../Pop-up.aspx #pop-up", createDatePicker)
          .dialog({
             position: 'center',
             width: 550 
          });
        // code .....
    });
});

Your datepicker creation code is now inside its own function, and is set as the callback when the popup page is loaded. This way, the datepicker will be created as soon as the page is loaded.

2
  • thanks @karl now i can see "buttonImage: "../images/calendar-icon.png"" that is mean code is working but i don not see the datepicker :( Commented May 8, 2012 at 0:31
  • 1
    ok now i know what is the problem "Z-index" stackoverflow.com/questions/715677/… Commented May 8, 2012 at 0:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.