overlay does not work after enabling my custom module I am using latest Drupal 7.

I just noticed my admin overlay is not working. 

First I thought its due to Jquery Update contrib module installation however that not it.
 Its apparently due to my custom module, overlay works if I uninstall my module.

My module consists of few basic hooks like hook_menu, hook_form, etc and a simple js file with delete confirm popup code in it.

Also in Home » Administration » Structure » Content types » Basic page, in manage fields tab, 'select a widget' select list (dropdown) shows all options. It is suppose to show options according to field type selected.

$(function() { 
 $(document).ready(function () {

  $(".del-link").click(function () {
   var answer = confirm("This action will delete this record?")
    if (answer){ // if yes is clicked on the confirm box.
     var del_record_id = this.id; // get record id that needs to be deleted.
      window.location = "/delete_url/" + del_record_id; // go to url which trigs the delete function and the record is deleted.
    }   
  });

  $("#edit-my-form-field").click(function () {
    $("#edit-my-form-field").is(":checked") ? $("#show-hide-div").hide() : $("#show-hide-div").show(); 
  }); // end of click function.

 }); // end of  $(document).ready(function ().
}); // end of $(function().


Has anyone come across similar issue?
I figured (googled) it out. :)

I added my custom js in my custom module's info file instead of using drupal_add_js in my module directly.


scripts[] = my_module.js


and added drupal behaviors in my js file as well, so now my custom js looks like below


(function ($) {
Drupal.behaviors.my_module = {
attach: function (context) {

// my js code

 }
};
})(jQuery);


I spent many hours figuring this out but it was as simple as could be be.

Hope this helps someone! :)