Dan Ehrmann
Top achievements
Rank 1
Dan Ehrmann
asked on 10 May 2012, 08:43 PM
I have a paragraph in the editor lie this (looking at html view):
<p class="some-class">some text</p>
When the user presses 'Enter' to create a new line, the class is repeated:
<p class="some-class"> </p>
I would prefer that a new line create a <p> without the class - how can I make this happen?
<p class="some-class">some text</p>
When the user presses 'Enter' to create a new line, the class is repeated:
<p class="some-class"> </p>
I would prefer that a new line create a <p> without the class - how can I make this happen?
3 Answers, 1 is accepted
0
Hi,
Here is an example on how to strip the className attribute of the newly inserted paragraph:
Greetings,
Rumen
the Telerik team
Here is an example on how to strip the className attribute of the newly inserted paragraph:
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head id=
"Head1"
runat=
"server"
>
<title></title>
<style type=
"text/css"
>
.first_p_only { background-color: Red; }
</style>
</head>
<body>
<form id=
"form1"
runat=
"server"
>
<asp:ScriptManager ID=
"Scriptmanager1"
runat=
"server"
/>
<script type=
"text/javascript"
>
function
OnClientCommandExecuted(editor, args) {
var
command = args.get_commandName();
if
(command ==
"EnterNewLine"
) {
if
($telerik.isIE) {
editor.get_contentWindow().setTimeout(
function
() {
var
parent = editor.getSelection().getParentElement();
parent.className =
""
;
var
selection = editor.getSelection();
selection.selectElement(parent);
selection.collapse(
true
);
}, 0);
}
else
{
var
parent = editor.getSelection().getParentElement();
parent.className =
""
;
var
selection = editor.getSelection();
selection.selectElement(parent);
selection.collapse(
true
);
}
}
}
</script>
<telerik:RadEditor runat=
"server"
OnClientCommandExecuted=
"OnClientCommandExecuted"
NewLineMode=
"P"
ImageManager-ViewPaths=
"~/Images"
ImageManager-UploadPaths=
"~/Images"
ID=
"RadEditor1"
>
<Content>
<p class=
"first_p_only"
>Only the first paragraph should be styled.</p>
</Content>
</telerik:RadEditor>
</form>
</body>
</html>
Greetings,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Dan Ehrmann
Top achievements
Rank 1
answered on 15 May 2012, 04:01 PM
Thanx Rumen - I will try this
is this browser behavior? or radeditor behavior?
is this browser behavior? or radeditor behavior?
0
Hello,
It is a browser behavior as you can see in the following test with editable iframe: http://screencast.com/t/D467IGeq.
All the best,
Rumen
the Telerik team
It is a browser behavior as you can see in the following test with editable iframe: http://screencast.com/t/D467IGeq.
All the best,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.