2014-07-04 32 views
0

對於我目前正在使用的軟件,我正在爲我們的內部幫助文檔做一個小小的CMS,但我一直在嘗試使用TinyMCE,以便他們可以輕鬆地應用符合我們外觀和風格的樣式,而無需理解HTML。我有我需要的所有自定義按鈕,但是我最終的自定義按鈕有問題。TinyMCE 4 - getContent()未從對話框輸入字段接收值

我們需要的是一個按鈕,它會自動將他們輸入的一個單詞當作查詢字符串參數(FindWord?Word = [輸入字段]),當稍後點擊頁面時,會彈出一個隱藏的div和錨點到術語詞彙。然而getContent()函數似乎並沒有爲我工作,經過超過12個多小時的搜索,並嘗試了大量的例子,我似乎無法讓它工作。

其他細節我不知道是很重要的:
- 使用MVC 4剃刀意見,TinyMCE的4與TinyMCE.Jquery包。
- 這是問題的輸入字段:http://i.imgur.com/wrMoTOP.png

任何幫助將是偉大的!謝謝!

<script type="text/javascript"> 
tinyMCE.init({ 
    mode: "specific_textareas", 
    editor_selector: "mceEditor", 
    theme: "modern", 
    plugins: "pagebreak,textcolor,layer,table,save,hr,image,link,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,fullscreen,visualchars,nonbreaking,template,wordcount,code,customcss_1,customcss_2", 
    menubar: "edit format view table tools", 
    toolbar: "undo redo print glossaryword | fontsizeselect | forecolor backcolor | bold italic underline strikethrough | outdent alignleft aligncenter alignright alignjustify indent | bullist numlist hr |", 
    contextmenu: "undo redo | cut copy paste | link | customcss_1 customcss_2 glossaryword |", 
    height: 500, 
    setup: function (ed) { 
     ed.addButton('glossaryword', { 
      title: 'Query String Parameter', 
      onclick: function() { 
       ed.windowManager.open({ 
        title: 'Query String Parameter', 
        body: [ 
        { type: 'textbox', name: 'source', label: 'Source' } 
       ], 
        onsubmit: function (e) { 
         ed.focus(); 
         ed.selection.setContent('<a href="FindWord?Word=' + ed.selection.getContent() + '">' + ed.selection.getContent() + '</a>'); 
        } 
       }); 
      } 
     }); 
    } 
});  

+0

在'onsubmit'後'ed.focus試試這個();' - >'ed.triggerSave()'或'tinyMCE.triggerSave()'。或者,你可以試試這個'tinyMCE.activeEditor.selection.getContent()' – MightyLampshade

+0

@MightyLampshade tinyMCE.activeEditor.selection.getContent();不起作用。 tinyMCE.triggerSave();什麼也沒做。 ed.triggerSave();不是一個功能。 – user3803132

+0

請創建你的代碼的小提琴! –

回答

0

一段時間更長亂搞後,我才意識到我是愚蠢的。

setup: function (ed) { 
     ed.addButton('glossaryword', { 
      title: 'Query String Parameter', 
      onclick: function() { 
       ed.windowManager.open({ 
        title: 'Query String Parameter', 
        body: [ 
        { type: 'textbox', name: 'word', label: 'Glossary Word', id: 'popupword' } 
       ], 
        onsubmit: function (e) { 
         ed.focus(); 
         ed.selection.setContent('<a href="FindWord?Word=' + e.data.word + '">' + e.data.word + '</a>'); 
        } 
       }); 
      } 
     }); 
    } 
相關問題