Rich Textarea and AJAX Loading

This topic contains 13 reply and 2 voices, and was last updated by Tareq Hasan 11 years, 5 months ago
Viewing 13 Posts - 1 through 13 (of 13 total)
Author Posts
June 10, 2013 at 7:25 am 4722
Tareq Hasan Hi Tareq, I have a small issue here. Hi have 4 different forms with rich and normal textarea in 4 different pages. For some reasons, I have an other page with 4 buttons, one for each form. When the age is loaded, the first form is displayed. Not problem with the rich textarea at this point. Then I click on the second button, which load the second form through AJAX. But there, I have a problem rending the rich textarea... Could you help me ?
June 10, 2013 at 7:26 am 4723
noomia noomia This reply has been marked as private.
June 10, 2013 at 8:10 am 4726
Tareq Hasan Tareq Hasan

As far as I know, you can’t use tinymce with ajax. They can’t be initialized with ajax, only they can be initialized when the DOM is just ready.

June 10, 2013 at 8:12 am 4727
noomia noomia

I cant’ initialize tinymce when the ajax request is done ???

June 10, 2013 at 8:24 am 4728
Tareq Hasan Tareq Hasan

Seems like you can, the one I was talking about you can’t move through DOM once initialized. Anyway, this link will help you.

June 10, 2013 at 8:45 am 4731
noomia noomia

How do you initialize the TinyMCE in WPUF ?

June 10, 2013 at 9:25 am 4735
Tareq Hasan Tareq Hasan

I just call wp_editor()

June 10, 2013 at 9:29 am 4736
noomia noomia

If I call :

tinymce.init({
	selector: "textarea",
});

when the AJAX request is done, it works but I haven’t go the same theme as your tinyMCE… Do you know wich theme is used and what are the size generated with the wp-editor ?

June 10, 2013 at 9:37 am 4737
Tareq Hasan Tareq Hasan

Sorry, I’ve no idea.

June 10, 2013 at 9:46 am 4738
noomia noomia

Ok, I’ve found the right solution (I think) :

if ($('.page-template-create-post-php').length) {
	$('#createPostsMenu a').click(function(e){
		e.preventDefault();
		var href = $(this).attr('href');
		$.get(href)
			.done(function(data){
				//On ajoute les nouveaux articles
				$('#content .entry-content')
					.empty()
					.append($('#content .entry-content', data).html());
	            //init tinymce
	            tinymce.init(tinyMCEPreInit.mceInit['post_content']);
			})
			.fail(function(){
				alert('Fail');
			});
	});
}

Here is the line a call when the AJAX request is done :
tinymce.init(tinyMCEPreInit.mceInit['post_content']);

(post_content is the class of my textarea)

Thanks Tareq !

June 10, 2013 at 10:24 am 4747
noomia noomia

Same problem with the address field and the google map.

How do you load it ?

June 11, 2013 at 7:53 am 4781
Tareq Hasan Tareq Hasan

I load it via inline javascript.

June 11, 2013 at 7:58 am 4783
noomia noomia

Ok but could you tell me how exactly ? I would like to add it in my .js file when the AJAX request is succeed.

June 11, 2013 at 8:00 am 4784
Tareq Hasan Tareq Hasan

see the render-form.php for google map, you’ll see.

Viewing 13 Posts - 1 through 13 (of 13 total)