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

Selecting an object and Custom Dialog

2 Answers 57 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Matthew Green
Top achievements
Rank 1
Matthew Green asked on 23 Dec 2009, 11:09 AM
Here is what i am trying to achieve is:

Select an item (ie image in a unordered list) but automatically select the content for replacement to the <LI> (or anything that I would like it to be) level in the dom rather than the image.

This is to create some Html that is transformed for use with: jquery.lightbox

I already have some client script for a similar process:
function setYouTubeArea() { 
    Telerik.Web.UI.Editor.CommandList["YoutubeManager"] = 
    function(commandName, editor, args) { 
        var $e = getSelected(editor); 
        var available = youtubeFormat($e); 
 
 
 
        var insertFunction = 
            function(sender, args) { 
                //<a href="http://www.youtube.com/watch?v=qqXi8WmQ_WM"  
                //rel="prettyPhoto" title=""> 
                //<img src="images/thumbnails/flash-logo.jpg" alt="YouTube" width="60" /></a> 
                editor.pasteHtml( 
                        String.format( 
                            "<a href='http://www.youtube.com/watch?v={0}' rel='prettyPhoto' title='{1}'><img width='194' src='http://img.youtube.com/vi/{0}/0.jpg' alt='YouTube'/></a>"
                            args.href, 
                            args.title 
                        ) 
                    ) 
            } 
 
        var href = format.accessable ?  format.link.href.replace("http://www.youtube.com/watch?v="""): ""
        var title = format.accessable ? format.link.title: ""
        argument //= available.link; 
            = { href: "", title: ""}; 
        argument.href = href; 
        argument.title = title; 
 
        editor.showExternalDialog('/EditorDialogs/YouTubeManager.aspx', argument, 450, 400, 
            insertFunction, 
            null
            'Insert Link'
            true
            Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
            true
            true 
        ); 
    } 

1. If the user clicks on the image the dom will respond that the selected html is the image
2. if the selection corresponds to the correct object layout (already worked out in another method - ie youtube part: <a><img/></a>)
3. select outer html in the editor for replacement rather than just the image.

Otherwise i'm left with junk html that created unexpected results.

Second problem relates to this:
http://www.telerik.com/community/forums/aspnet-ajax/editor/object-embed-code-not-removed-in-firefox.aspx
In the version notes what kind of thing shall i look for?

Best Regards,
Matthew Green

2 Answers, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 23 Dec 2009, 12:12 PM
Hi Matthew,

1) You can use the editor.getSelectedElement() method to get a reference to the currently selected HTML element in the RadEditor for ASP.NET AJAX content area. Once you have the selected element check whether it is an image and loop through its parent elements until you found a LI tag.
Finally you can select the LI tag using the
editor.selectElement(elem); //selects the element

2) The second problem should be fixed in the latest internal build that we published yesterday. You can download it from here -> http://www.telerik.com/downloads/nightbuildfiles/dtg/Telerik.Web.UI_2009_3_1221_Trial_hotfix.zip

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Matthew Green
Top achievements
Rank 1
answered on 23 Dec 2009, 12:24 PM
That sound nice and easy. Thank you for the quick reply.
Tags
Editor
Asked by
Matthew Green
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Matthew Green
Top achievements
Rank 1
Share this question
or