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 .....
      });
   });
});
Tarek Saied
  • 6,482
  • 20
  • 67
  • 111

1 Answers1

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.

Karl Nicoll
  • 16,090
  • 3
  • 51
  • 65
  • thanks @karl now i can see "buttonImage: "../images/calendar-icon.png"" that is mean code is working but i don not see the datepicker :( – Tarek Saied May 08 '12 at 00:31
  • 1
    ok now i know what is the problem "Z-index" http://stackoverflow.com/questions/715677/trouble-with-jquery-dialog-and-datepicker-plugins – Tarek Saied May 08 '12 at 00:40