Home Forums Plugin Support WP User Frontend Pro Rich Textarea and AJAX Loading

This topic is: resolved

This topic contains 13 replies, has 2 voices, and was last updated by  Tareq Hasan 5 years, 11 months ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #4722

    noomia
    Participant
    Post count: 115

    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 ?

    #4723

    noomia
    Participant
    Post count: 115
    This reply has been marked as private.
    #4726

    Tareq Hasan
    Keymaster
    Post count: 2831

    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.

    #4727

    noomia
    Participant
    Post count: 115

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

    #4728

    Tareq Hasan
    Keymaster
    Post count: 2831

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

    #4731

    noomia
    Participant
    Post count: 115

    How do you initialize the TinyMCE in WPUF ?

    #4735

    Tareq Hasan
    Keymaster
    Post count: 2831

    I just call wp_editor()

    #4736

    noomia
    Participant
    Post count: 115

    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 ?

    #4737

    Tareq Hasan
    Keymaster
    Post count: 2831

    Sorry, I've no idea.

    #4738

    noomia
    Participant
    Post count: 115

    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 !

    #4747

    noomia
    Participant
    Post count: 115

    Same problem with the address field and the google map.

    How do you load it ?

    #4781

    Tareq Hasan
    Keymaster
    Post count: 2831

    I load it via inline javascript.

    #4783

    noomia
    Participant
    Post count: 115

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

    #4784

    Tareq Hasan
    Keymaster
    Post count: 2831

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

Viewing 14 posts - 1 through 14 (of 14 total)

The topic ‘Rich Textarea and AJAX Loading’ is closed to new replies.