Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Thijs 97 posts 117 karma points
    Oct 28, 2011 @ 14:23
    Thijs
    0

    Custom tree javascript

     

    Hi community

    I have made a custom section with a custom tree using the tutorial videos on the umbraco website. This works fantastic (besides I need to click a default section first before my custom section will load) but when I click on my tree the javascript which is needed to load the right panel isn't fireing.. I searched this forum and the internet but I didn't found any posts with this problem. Does anyone know what is giving this problem or how to solve this? Here's my code for your information..

     

    using umbraco.cms.presentation.Trees; using umbraco.BusinessLogic; namespace CostumLogic.Trees.Newsletter { public class loadSubscribers : BaseTree { public loadSubscribers(string app) : base(app) { } protected override void CreateRootNode(ref XmlTreeNode rootNode) { rootNode.Icon = FolderIcon; rootNode.OpenIcon = FolderIconOpen; rootNode.NodeType = TreeAlias; rootNode.NodeID = "init"; } public override void RenderJS(ref System.Text.StringBuilder Javascript) { //best practice is om deze te noemen 'open' + de alias van je custom tree Javascript.Append( @" function openSubscribers() { alert('function is being called!'); parent.right.document.location.href = 'plugins/Newsletter/showNewsletterSubscribers.aspx; } "); } public override void Render(ref XmlTree tree) { XmlTreeNode xNode = XmlTreeNode.Create(this); xNode.NodeID = "1"; xNode.Text = "Subscribers"; xNode.Icon = "subscribers.gif"; xNode.Action = "javascript:openSubscribers()"; tree.Add(xNode); } } }

  • Thijs 97 posts 117 karma points
    Oct 28, 2011 @ 14:27
    Thijs
    0

    since I can't edit my post (this should realy be a workpoint for the webmasters) here's my code but readable:

    ps: when I hover over my node in the tree I can see it is using the javascript function given in the Render function.

    using umbraco.cms.presentation.Trees;
    using umbraco.BusinessLogic;
    
    namespace CustomLogic.Trees.Newsletter
    {
        public class loadSubscribers : BaseTree
        {
            public loadSubscribers(string app) :
                base(app) { }
    
            protected override void CreateRootNode(ref XmlTreeNode rootNode)
            {
                rootNode.Icon = FolderIcon;
                rootNode.OpenIcon = FolderIconOpen;
                rootNode.NodeType = TreeAlias;
                rootNode.NodeID = "init";
            }
    
            public override void RenderJS(ref System.Text.StringBuilder Javascript)
            {
                Javascript.Append(
                    @"
                        function openSubscribers()
                        {
                            alert('function is being called!');
                            parent.right.document.location.href = 
    'plugins/Newsletter/showNewsletterSubscribers.aspx; } "); } public override void Render(ref XmlTree tree) { XmlTreeNode xNode = XmlTreeNode.Create(this); xNode.NodeID = "1"; xNode.Text = "Subscribers"; xNode.Icon = "subscribers.gif"; xNode.Action = "javascript:openSubscribers()"; tree.Add(xNode); } } }
  • Thijs 97 posts 117 karma points
    Oct 28, 2011 @ 15:15
    Thijs
    0

    Mr Andy Rose at Stackoverflow.com found my problem. I was missing a ' at the end of my javascript function.. I looked over this...

Please Sign in or register to post replies

Write your reply to:

Draft