简体   繁体   English

使用TinyMCE的Joomla 2.5 jQuery

[英]Joomla 2.5 jQuery with TinyMCE

I've been looking around for a fair while today, and i cant seem to get it working. 我一直在寻找一个公平的日子,我似乎无法使它正常工作。

As i want to use the .remove() functions and its likes from jQuery, i thought it would be a "easy transition" over. 因为我想使用jQuery的.remove()函数及其类似功能,所以我认为这将是“轻松的过渡”。

Currently on Joomla 2.5.9, and trying to access TinyMCE in the article-editor. 当前在Joomla 2.5.9上,并尝试在文章编辑器中访问TinyMCE。

Anyone been able to do this? 有人能够做到吗?

I would need to load the content of that editor into a temporary div or var, then use somethign like $('#tmp').remove('...'); 我需要将该编辑器的内容加载到临时div或var中,然后使用诸如$('#tmp').remove('...'); and finally put it back in to the active editor. 最后将其放回活动编辑器中。

Problem is i keep getting null in return, regardless of what i try :( 问题是无论我尝试什么,我都会不断得到null:

You will need to go through the TinyMCE Javascript API to accomplish this. 您将需要通过TinyMCE Javascript API来完成此操作。 I have performed a similar task for a recent project and I can recommend the following approach: 我为最近的项目执行了类似的任务,因此我可以推荐以下方法:

tinyMCE.onAddEditor.add( function() {
    tinyMCE.activeEditor.onChange.add( function( ed ) {
         var content = ed.getContent();

         // process the content here
         // ...

         ed.setContent( content );
    });
});

The getContent() method returns the entire text in the editor frame, including the HTML tags. getContent()方法返回编辑器框架中的整个文本,包括HTML标记。 You could afterwards load it dynamically as HTML and manipulate it: 之后,您可以将其动态加载为HTML并进行操作:

$( content ).remove( '...' );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM