Question

I have been working on this for days but I don't get it so I decided to ask here. I really have a hard time tracing where is the problem is in my code.. here my code:

  $(".editME").click(function(){

      var element = $(this);
      var show = element.attr("id");

      $.get('index.php',{option:'myReports', task: 'edit', id: show},function(data)
      {
          $('body').html(data);
          $("#editFile").show(1000);
      });
      return true;
  });

When I click the edit button it while showing the whole page and inside of it I have the plugin datepicker. The problem is it doesn't show the calendar:

  $(function() {
      $("#datepicker").datepicker({
          changeMonth: true,
          changeYear: true
      });
  });

When I change the URL to index.php?option=myReports&task=edit.. the calendar appears.

My question: how can I load the calendar while I execute the editME?. Even if I return true it doesn't execute.

Was it helpful?

Solution

Well, you might be able to use

$("#datepicker").live("click", function(){
  $(this).datepicker({ changeMonth: true, changeYear: true });
});

Read up on the live() method. It makes jQuery recognize dynamically generated objects.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top