views:

48

answers:

1

I'm developing an ajax heavy web app, and would like to have textarea's (with class="ui-richtext") automatically initialize TinyMCE.

This is easy for textarea's that are loaded normally, but how about for content that is loaded AFTER the fact using ajax?

I was thinking something along these lines: (i'm using jquery)

$("textarea.ui-richtext").live("ajaxComplete", function()
{
    $(this).tinymce({...});
});

Unfortunately this doesn't seem to work. Any ideas?

This is my first post, let me know if I need to add more info

A: 

Live is limited to a small number of events.

You can do something like this though:

$.ajax({
    url: 'url/here',
    success: function(data){
        var $data = $(data).("textarea.ui-richtext").tinymce();
        $('#mydiv').append($data);
    }
});
PetersenDidIt
thanks for your response. I'm looking for an automatic way of doing this, as opposed to manually init'ing them each time (which violates DRY). I was thinking more along the lines of listening for ajaxComplete events, then running some function that is smart enough to initialize _new_ items (not re-initing existing items). I'd like to make this a generic solution so it would work with any type of dom+javascript (e.g. jquery ui elements, such as date pickers, tabs, etc). know what i mean? :)
Nick P.