per le persone che si stanno chiedendo come aggiungere una casella combinata personalizzato in nicEdit, ecco il mio post sul blog per visualizzare un menu a discesa personalizzato con valori dinamici
Link
Attraverso file di editing NiceEdit js possiamo aggiungi una casella combinata personalizzata in NicEdit
Attraverso il seguente modo possiamo aggiungere dropdown o combobox a NicEdit.È possibile ottenere il valore discesa dal database tramite chiamata AJAX e mostrarlo in NicEdit Prima di tutto scaricare e implementare NicEdit sulla aspx pagina Scarica il file NiceEdit js e si può attivarlo seguente codice (http://nicedit.com/)
<div style="height: 700px; width: 70%; overflow: scroll"> <div id="sample"><script type="text/javascript" src="../scripts/nicEdit.js"></script><script src="../nicExample/nicExample.js"></script>
<script type="text/javascript">
bkLib.onDomLoaded(function() {
// nicEditors.allTextAreas()
new nicEditor({ fullPanel: true }).panelInstance('area2');});</script>
<h4>NicEdit Textarea</h4><textarea name="area2" id="area2" style="width: 70%; height: 700px"> </textarea>
</div></div>
ora aggiungere getddlData) funzione di Ajax (nel file di niceEdit.js alla fine del file
// AJAX call
function getddlData() {
var ajaxResponse;
$.ajax({
type: "POST",
url: 'NicEdit.aspx/GetBookMarkData', // AJAX call to fecth dropdown data
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
cache: false,
// Text file name
success: function (response) {
// //alert(data.d); // or do some other data processing
// //return data.d;
ajaxResponse = response;
}
});
return ajaxResponse.d;
}
// Aggiungere un WebMethod in codebehind (cs file) per fetech valore di discesa in nicedit
012 file di
Ora aperto NicEdit js e la copia (Linea n 1552) o la ricerca seguente riga:
var nicEditorFontFormatSelect = nicEditorSelect.extend({
Copy complete function and create another one by changing names etc
var nicEditorInsertBookmark = nicEditorSelect.extend({
/* By Pankaj Sharma : Not Needed Now */
sel: {
'[[Location]]': "Test Name",
pre: "Test Address",
h6: "Test City",
h5: "Test State",
h4: "Test Zip",
h3: "Test ABC",
h2: "Test One",
},
init: function() {
/* Pankaj Sharma */
this.setDisplay("Insert Bookmark");
var response = getddlData();
var responseArr = response.split(",");
var strings = [];
//for (itm in this.sel) {
// // var A = itm.toUpperCase();
// //this.add( A, this.sel[itm] )
// }
for (i = 0; i < responseArr.length; i++) {
strings.push([responseArr[i], responseArr[i + 1]]);
i = i + 1;
}
for (var i in strings) {
this.add(strings[i][0], strings[i][1]);
}
/* END HERE*/
},
});
Got a linea 1230 o cercare seguente riga:
var nicSelectOptions = { pulsanti: { Add seguente sotto funzione fontFormat
'CustomBookmark': { nome: __ ('Inserisci segnalibro'), tipo: 'nicEditorInsertBookmark', // 012.351.641,061 milacomando: 'InsertBookmark' // InsertBookmark }
ora funzione di aggiornamento dovrebbe apparire così
var nicSelectOptions = {
buttons: {
'fontSize': {
name: __('Select Font Size'),
type: 'nicEditorFontSizeSelect',
command: 'fontsize'
},
'fontFamily': {
name: __('Select Font Family'),
type: 'nicEditorFontFamilySelect',
command: 'fontname'
},
'fontFormat': {
name: __('Select Font Format'),
type: 'nicEditorFontFormatSelect',
command: 'formatBlock'
},
'CustomBookmark': {
name: __('Insert Bookmark'),
type: 'nicEditorInsertBookmark', //
command: 'InsertBookmark' //InsertBookmark
}
}
};
linea Ora goto 1385 o aggiornamento: la funzione (A) { Change a
update: function (A) {
// alert(this.options.command);
if (this.options.command == 'InsertBookmark') {+
var editor = nicEditors.findEditor("area2");
var range = editor.getRng();
var editorField = editor.selElm();
editorField.nodeValue = editorField.nodeValue.substring(0, range.startOffset) + A + editorField.nodeValue.substring(range.endOffset, editorField.nodeValue.length);
}
else {
// alert(A);
/* END HERE */
this.ne.nicCommand(this.options.command, A);
}
this.close()
}
Su Opzioni DropDown fare clic su Questo aggiungerà valore di discesa nel testo Editor sulla posizione del cursore.
FINE, si dovrebbe in grado di vedere i risultati
Ciao Klaus, ho avuto lo stesso problema ma ho usato .html() al posto di .test() in quanto la funzione .text() invia solo il testo e non la formattazione HTML informazioni necessarie per memorizzare la formattazione del testo. Lo sto facendo bene ?? –
Questo quello che stavo cercando. Avevo bisogno del codice html e non del testo non formattato. Grazie per la condivisione. – Theodoros80