我有一个使用EmberJS创建的单页应用程序.
我在页面上有3个textareas.
一旦textarea被插入到dom中,我正在渲染ckeditor,并且我在控制器上标记了一个属性,记录了ckeditor已被渲染,因此我不会渲染多次.
我甚至在调查dom以确认当前没有编辑器.
刷新页面时,我随机收到此错误:
Uncaught TypeError: Cannot call method 'unselectable' of null
Run Code Online (Sandbox Code Playgroud)
我不知道是什么导致它或现在阻止它.当它没有抛出该错误时,所有3个ckeditor看起来都很好.
这是我的编辑器的启动代码:
Lrt.PrioritizationEditableTextArea = Ember.TextArea.extend({
areaVisible: false,
isRendered: false,
isInserted: false,
didInsertElement:function(){
this.set('isInserted', true);
},
renderEditor:function(){
var self = this;
var selfID = self.get('elementId');
if( !this.get('isRendered') && this.get('isInserted') && $('#'+selfID).parent().find('cke').length === 0 ){
var editor = $('#'+selfID).ckeditor({
toolbar:[
{ name: 'document', items:['Source'] },
{ name: 'clipboard', items:['Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
{ name: 'editing', items:['scayt']},
{ name: 'basicstyles', items:['Bold', 'Italic', 'Underline', 'TextColor', 'BGColor', '-', 'RemoveFormat']},
{ …Run Code Online (Sandbox Code Playgroud) 我基于这个例子:https: //jsfiddle.net/hL0pvaty/
但是popover必须包含一个html div,因此,我想要的是第一个和第二个链接之间的混合:https: //maxalley.wordpress.com/2014/08/19/bootstrap-3-popover-with-html -内容/
这是js代码:
$(document).on("click", ".show-popover-div", function (e) {
$('[rel="popover"]').popover({
container: 'body',
html: true,
content: function () {
var clone = $($(this).data('popover-content')).clone(true).removeClass('hide');
return clone;
}
}).click(function(e) {
e.preventDefault();
});
});
Run Code Online (Sandbox Code Playgroud)
这有效,但迫使我双击链接,只需点击一下即可.
有一件事,这个例子非常好,但我需要应用一些更改,我想要相同的,但从链接,我打开一个加载json文件的模态窗口,
json文件有一个打开popover的图像链接,就像你给我看的那样(我使用bootstrap-table来加载json文件)
这是json文件:
[
{
"col1": "<a href='#'>13560431</a>",
"col2": "<a href='#' class='popup-window' data-placement='left'><img src='img/ico_add_td.png' /></a>"
},
{
"col1": "<a href='#'>44560422</a>",
"col2": "<a href='#' class='popup-window' data-placement='left'><img src='img/ico_add_td.png' /></a>"
}
]
Run Code Online (Sandbox Code Playgroud)
这是使用bootstrap-table加载json文件的js代码:
$("#table-alert2").bootstrapTable({
url: 'data-table-alert2b.json',
columns: [{
field: 'col1'
}, {
field: 'col2'
}, …Run Code Online (Sandbox Code Playgroud)