3 Answers, 1 is accepted
0
Hi,
You can use the editor.getSelectedElement() method to check whether the selected element is A tag and if it is to disable the Unlink button using the setState() method. This could be implemented in the OnClientSelectionChange event of RadEditor.
All the best,
Rumen
the Telerik team
You can use the editor.getSelectedElement() method to check whether the selected element is A tag and if it is to disable the Unlink button using the setState() method. This could be implemented in the OnClientSelectionChange event of RadEditor.
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.
0
Trevor
Top achievements
Rank 1
answered on 25 May 2012, 10:37 PM
Hi Rumen,
Thanks for the response. I implemented the following code:
function OnClientSelectionChange(editor, args){
var elem = editor.getSelectedElement();
var tool=editor.getToolByName("Unlink");
if((tool)&&(elem.tagName == "A")){
tool.setState(0);
}else{
tool.setState(-1);
}
}
This does correctly set the state of the toolbar button; however, immediately after completing execution of this function, the toolbar button becomes unconditionally enabled again. It seems the editor is executing some other code that sets the state of the toolbar button after calling this function.
Thanks for the response. I implemented the following code:
function OnClientSelectionChange(editor, args){
var elem = editor.getSelectedElement();
var tool=editor.getToolByName("Unlink");
if((tool)&&(elem.tagName == "A")){
tool.setState(0);
}else{
tool.setState(-1);
}
}
This does correctly set the state of the toolbar button; however, immediately after completing execution of this function, the toolbar button becomes unconditionally enabled again. It seems the editor is executing some other code that sets the state of the toolbar button after calling this function.
0
Hi,
Try with small timeout, e.g.
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientSelectionChange="OnClientSelectionChange">
<Content><a href="http://www.telerik.com">Telerik</a></Content>
</telerik:RadEditor>
<script type="text/javascript">
function OnClientSelectionChange(editor, args) {
var elem = editor.getSelectedElement();
var tool = editor.getToolByName("Unlink");
if ((tool) && (elem.tagName == "A")) {
setTimeout(function () {
tool.setState(-1);
}, 100);
}
}
</script>
Greetings,
Rumen
the Telerik team
Try with small timeout, e.g.
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientSelectionChange="OnClientSelectionChange">
<Content><a href="http://www.telerik.com">Telerik</a></Content>
</telerik:RadEditor>
<script type="text/javascript">
function OnClientSelectionChange(editor, args) {
var elem = editor.getSelectedElement();
var tool = editor.getToolByName("Unlink");
if ((tool) && (elem.tagName == "A")) {
setTimeout(function () {
tool.setState(-1);
}, 100);
}
}
</script>
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.