New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

args.get_name is not a function when executing the OnClientCommandExecuting event

Environment

Product RadEditor for ASP.NET AJAX

Description

Learn how to fix the

  • Uncaught TypeError: args.get_name is not a function at Array.OnClientCommandExecuting error
  • Uncaught TypeError: args.get_value is not a function at Array.OnClientCommandExecuting error
  • Uncaught TypeError: args.get_commandName is not a function at Array.OnClientCommandExecuting

errors when the OnClientCommandExecuting or OnClientCommandExecuted events are fired.

Solution

You can prevent the error with this if check - if (!args || !args.get_commandName) return; e.g.

<script>
function OnClientCommandExecuting(editor, args) {
    if (!args || !args.get_commandName) return;   
    var name = args.get_name();
    var val = args.get_value();
    var cArea = editor.get_contentArea();
    var selectedElement = editor.getSelectedElement();
}
</script>

or by using the private API:

<script>
function OnClientCommandExecuting(editor, args) {
    var name = args._name;
    var val = args._value;
    var cArea = editor._contentArea;
    ...
}
</script>
In this article