The problem with the Live method

The problem with the Live method

Hi!

I'm developing a plugin that fired the popup with the form for editing one paramater, and then save it via ajax. I cutted almost all the code from the plugin for showing you the heart of the problem.

As you can see in the snippet of code below I just add the click handler in which i call the alert:

  1. (function($) {
  2.       $.fn.sdialog = function(options) {
  3.           $.fn.sdialog.defaults = {
  4.                'title' : 'Title',
  5.                // some options here...
  6.         };
  7.           options = $.extend($.fn.sdialog.defaults, options);
  8.           return this.each(function() {
  9.             $(this).live('click', function() {
  10.                 alert('d');
  11.             });
  12.           });
  13.       }
  14. })(jQuery);

And here how I call the plugin:

  1. $(function(){ 
  2.       $('.mylink').sdialog();
  3. });

But my desired alert has not appeared. I cant understand where I have made the mistake. It's because of live function, cause if I just write the click function, all work fine:

  1. $(this).click(function() {
  2. ....

But I need to add the handler to new created elements, so the live method is I desire to use. The version of jQuery is 1.4.2.

So can you tell me please, what have I done wrong?