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:
- (function($) {
- $.fn.sdialog = function(options) {
- $.fn.sdialog.defaults = {
- 'title' : 'Title',
- // some options here...
- };
- options = $.extend($.fn.sdialog.defaults, options);
- return this.each(function() {
- $(this).live('click', function() {
- alert('d');
- });
- });
- }
- })(jQuery);
And here how I call the plugin:
- $(function(){
- $('.mylink').sdialog();
- });
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:
- $(this).click(function() {
- ....
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?