2009-12-13 98 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