According to the LiveQuery documentation (http://brandonaaron.net/docs/
livequery) the 'registerPlugin' functionality is for plug-ins that
modify the DOM without the aid of jQuery, which is not your case. I
believe you'd have to bind an event to the a.delete elements for that
to work:

function confirm() {
        return window.confirm("Are you sure you want to " +
this.innerHTML.toLowerCase() + "?");
};

jQuery(document).ready(function($) {
    $('a.delete').livequery('click',confirm);
    $('a.ajax').click(function(){
        $(this).parent().append('<p><a href="#"
class="delete">Delete</
a></p>');
        return false;
    });

});

if you want to keep your confirm() as a plugin, this might work but is
much more complicated and adds extra overhead:

$.fn.confirm = function() {
   $(this).data('confirm_plugin',true);
    this.click(function() {
        return window.confirm("Are you sure you want to " +
this.innerHTML.toLowerCase() + "?");
    });
};

jQuery(document).ready(function($) {
    $('a.delete').livequery('mouseenter',function(){
       if (!$(this).data('confirm_plugin')) $(this).confirm().click();
    });
    $('a.ajax').click(function(){
        $(this).parent().append('<p><a href="#"
class="delete">Delete</
a></p>');
        return false;
    });

});

Alternatively you could simply call confirm() after every append.

- ricardo

On Dec 8, 8:17 am, "R. Rajesh Jeba Anbiah"
<[EMAIL PROTECTED]> wrote:
>    [Posted to 
> jquery-devhttp://groups.google.com/group/jquery-dev/msg/c33c84a2db495f88
> and then realized that it may get better response here]
>
>     I'm trying to register a simple plugin with livequery, but it
> doesn't work as expected.
>
> Code snippet:
>
> $.fn.confirm = function() {
>     this.click(function() {
>         return window.confirm("Are you sure you want to " +
> this.innerHTML.toLowerCase() + "?");
>     });
>
> };
>
> if ($.livequery) {
>     $.livequery.registerPlugin('confirm');
>
> }
>
> Testing:
>
> <p><a href="#" class="delete">Delete</a></p>
> <p><a href="#" class="ajax">Ajax apend</a></p>
>
> jQuery(document).ready(function($) {
>     $('a.delete').confirm();
>     $('a.ajax').click(function(){
>         $(this).parent().append('<p><a href="#"
> class="delete">Delete</
> a></p>');
>         return false;
>     });
>
> });
>
>      Any idea, why it's not working? TIA
>
> --
>   <?php echo 'Just another PHP saint'; ?>
> Email: rrjanbiah-at-Y!com    Blog:http://rajeshanbiah.blogspot.com/

Reply via email to