Here is the challenge I'm struggling with. I have a user that wants to be able to tab through the different tabs with bootstrap tabs that are in a single ckeditor instance. I understand the reasons why links are disabled for most a tags, but would like to allow the event to occur for just these tab links. I've attached a screenshot showing the editor with a bootstrap tab region in the content.
Basically, if the user hits "Facilities", "Products", "Partners" or "Sustainability" I would like the associated view below to show so the user could edit the content for each tab-pane.
Link to Fiddle showing the issue: jsFiddle Sample
<!-- CK Editor -->
<div id="editor1" name="editor1">
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li class="active"><a href="#home" data-toggle="tab">Home</a></li>
<li><a href="#profile" data-toggle="tab">Profile</a></li>
<li><a href="#messages" data-toggle="tab">Messages</a></li>
<li><a href="#settings" data-toggle="tab">Settings</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="home">Home Content</div>
<div class="tab-pane" id="profile">Profile Content</div>
<div class="tab-pane" id="messages">Messages Content</div>
<div class="tab-pane" id="settings">Settings Conent</div>
</div>
</div>
I ended up recreating the event with CKEditor. Here is the code:
CKEDITOR.scriptLoader.load('http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js');
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
var editor1 = CKEDITOR.replace('editor1', {
// Custom stylesheet for the contents
contentsCss: 'http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css'
});
editor1.on('contentDom', function () {
var elements = editor1.document.getElementsByTag('a');
for (var i = 0, c = elements.count(); i < c; i++) {
var e = new CKEDITOR.dom.element(elements.$.item(i));
// enable the specific issue of bootstrap tabs working
if ($(e).is("[data-toggle]")) {
e.on('click', function () {
var tab = $(this.$);
var attr = tab.attr("href");
var doc = $(editor1.document.$);
// update tabs
tab.closest(".nav-tabs").find("li").removeClass("active");
tab.parent().addClass("active");
// update tab panes
doc.find(".tab-pane").removeClass("active");
doc.find(attr).addClass("active");
});
}
}
});