2009-12-13 145 views
0

我正在使用TinyMCE並希望執行一個php腳本獲取輸出併發布輸出。
我試圖插入我的代碼與數據預填充的PHP腳本。TinyMCE自定義按鈕按問題

有人可以幫助我這個。我是一個JavaScript新手..

這是我的代碼插入單個實例沒有數據。 (該代碼的其餘部分是直接從文件API的例子)

/////////////////////////////////////////////////////////////////////////////// 
      ed.addCommand('mceCommandHere', function() { 
      ed.execCommand('mceInsertContent',false,'[CODEHERE ="" URL ="" Title=""]'); 
      }); 
      ed.addButton('CommandHere', { 
       title : 'Add Subscriptions', 
       cmd : 'mceCommandHere', 
       image : url + '/PictureHere.png' 
      }); 
      ed.onNodeChange.add(function(ed, cm, n) { 
       cm.setActive('CommandHere', n.nodeName == 'IMG'); 
      }); 
      /////////////////////////////////////////////////////////////////////////////// 

回答

1

我理解了它的textarea標籤! YEAH!它只看着我做2天!

  /////////////////////////////////////////////////////////////////////////////// 
     ed.addCommand('mceCommandHere', function() { 
      var mydata; 
      tinymce.util.XHR.send 
      ({ 
        url : url + "/CommandHere.php", 
        content_type : "text/html", 
        type : "GET", 
        data : tinymce.util.JSON.serialize({ 
         param1 : "TinyMCE" 
        }), 
        async : false, 
        scope : ed, 

        success : function(data, req, o) { 
         mydata = data; 
        }, 

        error : function(type, req, o){ 
         alert('Something Went Wrong, Please Check your Installation. Error Type: '+ type +' Error Status: '+req.status); 
        } 
      }); 

     ed.execCommand('mceInsertContent',false, mydata); 
     }); 
     ed.addButton('CommandHere', { 
      title : 'CommandHere', 
      cmd : 'mceCommandHere', 
      image : url + '/CommandHere.png' 
     }); 
     ed.onNodeChange.add(function(ed, cm, n) { 
      cm.setActive('CommandHere', n.nodeName == 'IMG'); 
     }); 
     /////////////////////////////////////////////////////////////////////////////// 
0

不知道你的意思,但PHP總是JS之前執行,除非你有一些Ajax回事。 所以你可以插入你的數據庫內容的權利爲所使用的TinyMCE的

<textarea name="content"><?php echo $my_data ?></textarea> 
+0

感謝您的意見,這不是我一直在尋找的。我需要它輸入一個按鈕點擊。無論如何感謝您的幫助。 – Brad 2009-12-13 12:39:16