2015-12-29 69 views
0

我想通過TinyMCE的一個屬性添加到錨標記附加屬性來定位標記在TinyMCE的

目前的案文我已經是

​​3210

需要的輸出是

<p><a id="1212" title="abc" href="../abc" sampletest="true" target="_blank">Test</a></p> 

我只是想添加屬性sampletest =「true」到現有的錨定標記

以下將添加一個類,但我想添加一個屬性,如上面所要求的輸出。

$scope.tinymceOptions.style_formats = [ 
{ title: 'test', selector : 'a', classes: 'sampletest'} 
]; 

回答

2

可以使用

tinyMCE.dom.setAttrib('Element', 'String', 'String'); 

這裏,

:DOM元素,元件ID字符串或元件/ IDS的數組來設置屬性上。

字符串:要設置的屬性的名稱。

字符串:在該值的屬性上設置的值是空值0或'',它將刪除該屬性。

例如:

// Sets an attribute to all paragraphs in the active editor 
tinyMCE.activeEditor.dom.setAttrib(tinyMCE.activeEditor.dom.select('p'), 'class', 'myclass'); 

// Sets an attribute to a specific element in the current page 
tinyMCE.dom.setAttrib('mydiv', 'class', 'myclass'); 
+0

我應該在哪裏添加此片段? 'init'後綴? – alex