Javascript modal breaks itself?

The code below opens a modal, and then executes a series of jQuery calls on some form controls. It works. Form submission works. Everything is great EXCEPT.... after you complete the form, or just close the modal, the anchor tags with the requestFeedback class stop responding, which means you can only execute this ONCE. If you refresh the page, all is well again until you click any of the request feedback links that have the requestFeedback class.

Where should I look to figure out what is causing this?

    $(".requestFeedback").click(function(e){
      /* Set the ID */
      var request_id = $(this).data('cid');
      $("#modalRequestID").text(request_id);

      $("#modalRequestFeedback").on('show.bs.modal', function(e){
        /* Hook the help link */
        $(".showRequestFeedbackHelp").click(function(e){
          $("#requestFeedbackHelp").toggle('slow');
        });
        /* Add select2() to the worker select */
        $("#getFeedbackFrom").select2({
          placeholder: "Get feedback from...",
          allowClear: true,
          width:'100%'
        });

        /* Make the date a calendar. */
        $("#feedbackDeadline").datetimepicker();

        /* Bind the submit button to do some work. */
        $("#sendFeedbackRequests").click(function(e){
          var sendTo = JSON.stringify($("#getFeedbackFrom").val());
          var requestor = <?php echo $current_user->users_id; ?>;
          var requirement_id = request_id;
          var ed = tinymce.get('feedbackMesage');
          console.log(ed);
          var message = ed.getContent();
          var due = $("#feedbackDeadline").val();

          $.ajax({
            url:'<?php echo getHostFQDN(); ?>util/createReviewRequests.php',
            data:{
              sendTo : sendTo,
              requestor : requestor,
              requirement_id : requirement_id,
              message : message,
              due : due
            }
          }).done(function(data){

          })          
        })

        /* Add tinymce to the message. */
        tinymce.init({
          selector:'#feedbackMesage',
          menubar:false,
          toolbar:"undo redo | bold italic | bullist numlist | link unlink",
          width:'100%',
          plugins: "link,mention",
          mentions:
          {
            delay: 100,
            source: function(query, process)
                {
                  //Do your ajax call
                  $.getJSON('/util/queryMention.php?q=2&pid=76&b=170', function(data) {
                    //call process to show the result
                    process(data)
                  })
                }
          },
        });

      });
      $("#modalRequestFeedback").modal();
    });

Open in new window

LVL 32
DrDamnitAsked:
Who is Participating?
 
DrDamnitAuthor Commented:
Setting the date fixed it:
Selection-041.png
0
 
DrDamnitAuthor Commented:
Additional information:

After I click the button, then close the modal, then click it again, I get this in Firebug:
Selection-035.png
I also, as a test, removed the $("#modalRequestFeedback").on('show.bs.modal', function(e){ ... } section, and tested. The problem went away (of course the form becomes pointless at that point). But, the good news is: I've narrowed it down to that section of the code...
0
 
DrDamnitAuthor Commented:
OK, now I've narrowed it down to this line:
Selection-036.png
If I remove the datetimepicker(), it resolved the problem. So, the question not becomes: how do I fix the datetimepicker() in order to maintain its use?

Perhaps there are options I should use?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.