Jump to content

problem tinymce with ajax jquery


Petani

Recommended Posts

hi all. i have problem with tinymce n jquery, i use tinymce for textarea below:

i have form like this:

<div id="out_form_login">
</div>
<div id="form_profile">
<form>
<table>
<tr>
<td class="title">My Profile</td>
</tr>
<tr>
<td>
<textarea name="profil_my" cols="100" rows="25"> </textarea></td>
</tr>
<tr>
<td align="right">
<input type="submit" name="save_profil" value="save">
</td>
</tr>
</table>
</form>
</div>

 

i have jquery ajax:

$('#form_profile form').submit(function()
{
$('#out_form_login').empty();
$.post('save_profile.php',$(this).serialize(),function(data)
{
$("#out_form_login").show();
$('#out_form_login').html(data);
});
return false;
});

 

when i try to click save button to save the text in textarea(using tinymce) to DB, it didn't work, but when i click the save button once again, it works.

i confuse how could this happen.

is something wrong with my code?? thanks b4.

Link to comment
https://forums.phpfreaks.com/topic/266710-problem-tinymce-with-ajax-jquery/
Share on other sites

oh ya friend, i forget to add, $(document).ready() function, this is the true:

 

$(document).ready(function()
{
$('#form_profile form').submit(function()
{
$('#out_form_login').empty();
$.post('save_profile.php',$(this).serialize(),function(data)
{
$("#out_form_login").show();
$('#out_form_login').html(data);
});
return false;
});
});

 

it's still the same, i have to click twice save button to save the data.

thanks for the response my friend,

so you mean, just like this?

 

<div id="out_form_login">
</div>
<div id="form_profile">
<form method="POST"> <!--  add POST method -->
<table>
<tr>
<td class="title">My Profile</td>
</tr>
<tr>
<td>
<textarea name="profil_my" cols="100" rows="25"> </textarea></td>
</tr>
<tr>
<td align="right">
<input type="submit" name="save_profil" value="save">
</td>
</tr>
</table>
</form>
</div>

 

it's still the same, i have to click save button twice to save it to DB successfully.

i've tried to non-active tinymce, n become textarea normal , it works to save with just one click, but back, i active tinymce, it's back to its problem.

hi friend, i have found the way to solve it.

i just add tinyMCE.triggerSave();

so my ajax can be like this:

 

$(document).ready(function()
{
     $('#form_profile form').submit(function()
      {
              tinyMCE.triggerSave();
              $('#out_form_login').empty();
              $.post('save_profile.php',$(this).serialize(),function(data)
              {
                   $("#out_form_login").show();
                   $('#out_form_login').html(data);
             });
             return false;
       });
});

 

thanks for friend jazzman1 for trying to help me.

:)....

really helpful,...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.