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

Custom Dialogs not working

1 Answer 68 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Vincent asked on 27 Jun 2010, 02:07 AM
I've tried to copy everything from the online demo and try to make it work, but I cannot make it work.

I found the online demo description's script is different to the script in local demo file.


e.g. local file InsertSpecialLink

        Telerik.Web.UI.Editor.CommandList["InsertSpecialLink"] = function(commandName, editor, args) 
        { 
            var elem = editor.getSelectedElement(); //returns the selected element. 
 
            if (elem.tagName == "A"
            { 
                editor.selectElement(elem); 
                argument = elem.cloneNode(true); 
            } 
            else 
            { 
                var content = editor.getSelectionHtml(); 
                var link = editor.get_document().createElement("A"); 
                link.innerHTML = content; 
                argument = link; 
            } 
 
            var myCallbackFunction = function(sender, args) 
            { 
                editor.pasteHyperLink(args, "Insert Link"); 
            } 
 
            editor.showExternalDialog( 
            "InsertLink.aspx"
            argument, 
            270, 
            300, 
            myCallbackFunction, 
            null
            "Insert Link"
            true
            Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
            false
            true); 
        }; 

Online demo description's script

    <script type="text/javascript"
    Telerik.Web.UI.Editor.CommandList["InsertSpecialLink"] = function(commandName, editor, args) 
    { 
       var elem = editor.getSelectedElement(); //returns the selected element. 
               
       if (elem.tagName == "A"
       { 
            editor.selectElement(elem); 
            argument = elem; 
       } 
       else 
       { 
            //remove links if present from the current selection - because of JS error thrown in IE 
            editor.fire("Unlink"); 
                 
            //remove Unlink command from the undo/redo list 
            var commandsManager = editor.get_commandsManager(); 
            var commandIndex = commandsManager.getCommandsToUndo().length - 1; 
            commandsManager.removeCommandAt(commandIndex); 
 
            var content = editor.getSelectionHtml(); 
 
            var link = editor.get_document().createElement("A"); 
 
            link.innerHTML = content; 
            argument = link;         
        } 
        
       var myCallbackFunction = function(sender, args) 
       { 
           editor.pasteHtml(String.format("<a href={0} target='{1}' class='{2}'>{3}</a> ", args.href, args.target, args.className, args.name)) 
       } 
        
       editor.showExternalDialog( 
            'InsertLink.aspx'
            argument, 
            270, 
            300, 
            myCallbackFunction, 
            null
            'Insert Link'
            true
            Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
            false
            false); 
    }; 
    </script> 
 

When I tried different script, it never worked, the error I received error message "linkUrl.value is null", can you give a working version?



1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 30 Jun 2010, 04:30 PM
Hi Vincent,

I believe the local demo example that you are using is rather old. We made a small fix in the custom link command in order to provide the same behavior under different browsers.

You are the first one to report this problem. The linkUrl object is from the custom link dialog's page (InsertLink.aspx). Have you made any customization to the example code? If so could you please provide the modified code so we can investigate it further?

For your convenience I have attached a sample project with the custom link dialog's live demo.

Best wishes,
Dobromir
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Editor
Asked by
Vincent
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or