2016-09-29 46 views
0

我正面臨jquery wysiwyg的問題。新編輯的文本正在更新並保存在數據庫中時,會發生該問題。問題在於我保存的文本沒有佈局(例如沒有粗體或換行符)發佈到數據庫。所有的文字都被粘貼並一個接一個地卡住。數據庫字段被設置爲TEXT。jquery wysiwyg帖子佈局問題

例子:

這是一個大膽的文字

這是一個新的生產線

保存之後就變成了:這是一個大膽的textThis是一個新行

誰能幫助我出去了?

在PHP代碼

$mails = $db->search('mail'); 
$tpl->assign('mails', $mails); 

if ($_POST['save']) { 
foreach($mails as $mail) { 
    $db->id = $mail['MailID']; 
    $db->text = $_POST['text'.$mail['MailID']]; 
    $db->save('mail'); 
} 
header('Refresh: 0'); 
} 

http://imgur.com/a/fxUmU看到圖像的問題


碼單頁

{literal} 
    <script> 
     $(document).ready(function() { 
      var editors = $('#form textarea'); 
      $.each(editors, function() { 
       $(this).wysiwyg(); 
      }); 
     }); 
    </script> 
{/literal} 

     <!-- START CONTENT --> 
     <div class="content"> 
      <form method="post" action="" id="form" enctype="multipart/form- data"> 

       <!-- START jWYSIWYG TEXT EDITOR --> 
       {foreach from=$mails item=mail} 
        <div class="simplebox grid740"> 
         <div class="titleh"> 
          <h3>{$mail.title}</h3> 
         </div> 
         <div class="body"> 
          <textarea class="st-forminput"   name="text{$mail.MailID}" rows="5" cols="47" style="width:96.5%;">{$mail.text} </textarea> 
         </div> 
        </div> 
       {/foreach} 
       <!-- END jWYSIWYG TEXT EDITOR --> 

       <div class="button-box center"> 
        <input type="submit" name="save" id="button" value="Save"    class="st-button"/> 
       </div> 
      </form> 
+0

顯示你的部分代碼 – depperm

+0

「the」jquery wysiwyg?有一個jQuery的官方wysiwyg? – cstruter

+0

使用調試器查看要發送到服務器的內容。 – AndrewR

回答

0

首先,你應該確保你發佈的內容,實際上包含了html標籤。如果是,那麼試試這個保存https://stackoverflow.com/a/4577962/1084306。我相信你需要確保在插入之前對數據進行編碼。反之亦然,您需要將其解碼才能在頁面上呈現。

+0

我試過這個已經不行了 –

+0

你已經這樣做了嗎? 「確保你發佈的內容實際上包含了html標籤」。數據庫中的數據是什麼樣的? – Donovan

+0

是的,我試圖激活jWYSIWYG上的html,以確保發佈到數據庫的文本是html格式,但不知何故它仍然不會正確地發佈它 –