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
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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,...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.