This is a migrated thread and some comments may be shown as answers.

OnClientCommandExecuting Error

2 Answers 109 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 11 Jun 2012, 03:08 PM
I added a custom drop down to my editor. I created the OnClientCommandExecuting function to handle what happens when someone selects an item in the drop down.

The problem is the event fires when I press enter inside the editor, which is causing the following code to throw an error:

function OnClientCommandExecuting(editor, args) {
 
        var name = args.get_commandName();
        var val = args.get_value();
 
        var info = val.split("::");
 
    }

Error:

val is undefined
(?)(editor=Object { __msdisposeindex=3, _element=div#RadEditor1.RadEditor, _clientStateFieldID="RadEditor1_ClientState", more...}, args=Object { _cancel=false, _commandName="EnterNewLine", _name="EnterNewLine"})TelerikAjax.aspx (line 23)
createCallback(c=Object { __msdisposeindex=3, _element=div#RadEditor1.RadEditor, _clientStateFieldID="RadEditor1_ClientState", more...}, d=Object { _cancel=false, _commandName="EnterNewLine", _name="EnterNewLine"})Teleri...90a9d4e (line 6)
raiseEvent(b="commandExecuting", c=Object { _cancel=false, _commandName="EnterNewLine", _name="EnterNewLine"})Core.js (line 766)
createCallback(a=Object { __msdisposeindex=3, _element=div#RadEditor1.RadEditor, _clientStateFieldID="RadEditor1_ClientState", more...}, d="raiseEvent", b=["commandExecuting", Object { _cancel=false, _commandName="EnterNewLine", _name="EnterNewLine"}])Teleri...90a9d4e (line 6)
_responseReceived(c="commandExecuting", d=Object { _cancel=false, _commandName="EnterNewLine", _name="EnterNewLine"})RadEditor.js (line 6416)
_executeCommandEvent(s="commandExecuting", u="EnterNewLine", j=Object { _cancel=false, _commandName="EnterNewLine", _name="EnterNewLine"})RadEditor.js (line 7382)
fire(m="EnterNewLine", j=undefined)RadEditor.js (line 7363)
_onKeyDown(t=keydown charCode=0, keyCode=13)RadEditor.js (line 7814)
(?)(h=keydown charCode=0, keyCode=13)RadEditor.js (line 7739)
[Break On This Error]  
 
Reload the page to get source for: http://localhost:56444/TelerikAjax.aspx
 
TelerikAjax.aspx (line 23)

2 Answers, 1 is accepted

Sort by
0
Jeff
Top achievements
Rank 1
answered on 11 Jun 2012, 03:42 PM
I assume I'm just going to have to check to make sure the value came from the dropdown before I run my routine?
0
Rumen
Telerik team
answered on 12 Jun 2012, 02:02 PM
Hi,

You should also check for the executed command before executing your code, e.g.

function OnClientCommandExecuting(editor, args) {
        var name = args.get_commandName();
        if (name == "CustomDropdownCommandName)
        {
            var val = args.get_value();
            var info = val.split("::");
        }
}


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.
Tags
Editor
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jeff
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or