The standard RadEditor lacks a dialog to insert/edit DIV elements, so I built my own custom dialog to be able to do that.
Inserting the DV element works fine. However, editing an existing DIV does not. Instead of replacing the existing DIV element, a new DIV is created within the existing DIV.
In editing an existing DIV, how can I replace/update the existing DIV instead of inserting an extra one?
Best regards, Marja
Inserting the DV element works fine. However, editing an existing DIV does not. Instead of replacing the existing DIV element, a new DIV is created within the existing DIV.
Telerik.Web.UI.Editor.CommandList["InsertDIV"] = function (commandName, editor, args) { var argument = null, elem = editor.getSelectedElement(); //returns the selected element. if (elem && elem.tagName && elem.tagName == "DIV") { editor.selectElement(elem); argument = elem; } else { var l_sContent = editor.getSelectionHtml(); if (l_sContent == '') { l_sContent = 'Inhoud DIV...'; } var l_oDiv = editor.get_document().createElement("DIV"); l_oDiv.innerHTML = l_sContent; argument = l_oDiv; } var callbackInsertDIV = function (sender, args) { if (args != null) { var l_sStyle = "", l_sClass, l_sID, l_sContent = "Inhoud DIV..."; if (args.width && args.width != '') { l_sStyle += 'width:' + args.width + ';' } if (args.height && args.height != '') { l_sStyle += 'height:' + args.height + ';' } if (args.padding && args.padding != '') { l_sStyle += 'padding:' + args.padding + ';' } if (args.margin && args.margin != '') { l_sStyle += 'margin:' + args.margin + ';' } if (l_sStyle.length > 0) { l_sStyle = " style='" + l_sStyle + "'" } if (args.class && args.class != '') { l_sClass = " class='" + args.class + "'" } if (args.id && args.id != '') { l_sID = " id='" + args.id + "'" } if (args.content && args.content != '') { l_sContent = args.content } var l_sHtml = String.format("<div{0}{1}{2}>" + l_sContent + "</div>", l_sStyle, l_sClass, l_sID); editor.pasteHtml(l_sHtml); } } editor.showExternalDialog( 'RadEditor/dlgInsertDIV.aspx', argument, 600, 250, callbackInsertDIV, null, 'DIV element invoegen/wijzigen', true, Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Resize, false, true); };In editing an existing DIV, how can I replace/update the existing DIV instead of inserting an extra one?
Best regards, Marja
