views:

118

answers:

2

Hi

I been sort of using jquery livequery plugin and jquery live together. However now that I am using 1.4 it seems jquery livequery is not working 100%.

So I am not sure how to tackle this problem

I have this in livequery

$('#Description').livequery(function ()
{
    $('#Description').htmlarea({
        toolbar: [
            ["bold", "italic", "underline", "strikethrough", "|", "subscript", "superscript"],
            ["increasefontsize", "decreasefontsize"],
            ["orderedlist", "unorderedlist"],
            ["indent", "outdent"],
            ["link", "unlink"]
        ]
    });
});

So everytime I loaded up my page. It would actually run that code in the livequery and display and if I went to another ajax tab and come back it would go into this again.

Now I am not sure how to change it to .live() jquery 1.4 since I just tried to do this

$('#Description').live(function ()
{
    $('#Description').htmlarea({
        toolbar: [
            ["bold", "italic", "underline", "strikethrough", "|", "subscript", "superscript"],
            ["increasefontsize", "decreasefontsize"],
            ["orderedlist", "unorderedlist"],
            ["indent", "outdent"],
            ["link", "unlink"]
        ]
    });
});

and it does not seem to work. the plugin is not binded and the rich html editor is not displayed.

+2  A: 

You should still use .livequery() in this case...they operate in different ways, and .live() isn't suited for running plugins as elements are created dynamically.

.livequery() - Looks for new elements, executes when it finds them.
.live() - Listens for events to bubble up the DOM and execute on them, it's made for handling events from new or old elements and not caring when they were added, but it's not all that useful for executing plugins on newly created elements.

What problems are you having with .livequery() in 1.4.1? (1.4.2 is out by the way!)

Nick Craver
Seems like the error I was not getting was from livequery but a change from jquery 1.3 to 1.4 that was in one of the functions I wrote that used livequery. So thats why when I was not using livequery I did not get the error because I commented out that method.
chobo2
A: 

Outside of using livequery plugin, is there an 'built in' jQuery way to init a plugin on a dyncamically created element? We are also using htmlarea plugin (love it for simple wysiwyg editors!),.. but, now the element is being created by a drag/drop event..

revive