简体   繁体   English

在CK编辑器中访问选项卡数据

[英]Accessing Tab Data inside CK Editor

I have too many ckeditors on one page, which I've been told is the wrong way to go. 我在一页上有太多的ckeditors,有人告诉我这是错误的方法。 So, I found this stackflow example of Bootstrap Tab Panels and it would allow me to reduce the number of ckeditors because I'm thinking I could turn the space under each named tab into an editable space. 因此,我找到了这个Bootstrap选项卡面板的堆栈流示例,它使我减少了ckeditor的数量,因为我想可以将每个命名选项卡下的空间变成一个可编辑的空间。

Demo: http://jsfiddle.net/KyleMit/E6Tm4/ 演示: http//jsfiddle.net/KyleMit/E6Tm4/

<div id="editor1">

<!-- Nav tabs -->
<ul class="nav nav-tabs">
  <li class="active"><a href="#community_kgevents" data-toggle="tab">Events</a></li>
  <li><a href="#community_kgservicelearning" data-toggle="tab">Learning</a></li>
  <li><a href="#community_kgserviceprojects" data-toggle="tab">Projects</a></li>
  <li><a href="#community_kgvolunteering" data-toggle="tab">Volunteer</a></li>
  <li><a href="#community_kgcontent1" data-toggle="tab"><?php echo $community_kgsubtab1; ?></a></li>
  <li><a href="#community_kgcontent2" data-toggle="tab"><?php echo $community_kgsubtab2; ?></a></li>
  <li><a href="#community_kgcontent3" data-toggle="tab"><?php echo $community_kgsubtab3; ?></a></li>
</ul>

<!-- Tab panes -->
<div class="tab-content">
  <div class="tab-pane active" id="community_kgevents"><?php echo $community_kgevents; ?></div>
  <div class="tab-pane" id="community_kgservicelearning"><?php echo $community_kgservicelearning; ?></div>
  <div class="tab-pane" id="community_kgserviceprojects"><?php echo $community_kgserviceprojects; ?></div>
  <div class="tab-pane" id="community_kgvolunteering"><?php echo $community_kgvolunteering; ?></div>
  <div class="tab-pane" id="community_kgcontent1"><?php echo $community_kgcontent1; ?></div>
  <div class="tab-pane" id="community_kgcontent2"><?php echo $community_kgcontent2; ?></div>
  <div class="tab-pane" id="community_kgcontent3"><?php echo $community_kgcontent3; ?></div>
</div>

The name values in the Tab panes inside the div are the ones I need to capture and send to the mySQL database when I click the Submit button. div内“选项卡”窗格中的名称值是我单击“提交”按钮时需要捕获并发送到mySQL数据库的名称值。 I can get the Nab tabs named values from input type text fields, but the Tab pane named variables need a ckeditor. 我可以从输入类型文本字段中获取名为值的Nab选项卡,但是名为变量的“选项卡”窗格需要一个ckeditor。

Kyle has created a demo for this at http://jsfiddle.net/KyleMit/E6Tm4/5/ which works fine, but it isn't what I need because I need to capture all of the named value data when I click the Submit button at the bottom of the web page, which then sends all the data to the mySQL database and subsequently loads the profile web page containing the submitted data from the edit profile web page. 凯尔(Kyle)已在http://jsfiddle.net/KyleMit/E6Tm4/5/上为此创建了一个演示,它可以正常工作,但这不是我所需要的,因为当我单击提交时,我需要捕获所有命名的值数据网页底部的按钮,然后将所有数据发送到mySQL数据库,并随后加载包含来自编辑配置文件网页的已提交数据的配置文件网页。 Any help would be greatly appreciate on how this can be done. 任何帮助将不胜感激如何做到这一点。

You can extract tab information for all the tabs like this: 您可以像这样提取所有标签的标签信息:

var editorContent = CKEDITOR.instances['editor1'].getData();
$(editorContent).find(".tab-pane").each(function() {
    var tabContent = this.innerHTML;
    console.log(tabContent);
});

Demo in Fiddle 小提琴演示

Here I'm just logging them, but at the point you're handling each one you can do whatever modifications you need to do to submit it to the server. 在这里,我只是在记录它们,但是此时您正在处理每一个,您可以进行任何必要的修改以将其提交到服务器。 Preferably over an ajax request. 最好通过ajax请求。

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

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