Home - Forums-.NET - FlyTreeView (ASP.NET) - Prototype.js (Prototype javascript library) and flytreeview

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Prototype.js (Prototype javascript library) and flytreeview
Link Posted: 04-Nov-2008 12:41
Anyone try using the Prototype library with flytree?
http://prototype-window.xilinus.com/themes.html

When I include prototype.js, then expand a flytreeview node, I get a cryptic error:
Cannot instantiate a node that already has some owner (other node or treeview).

If I comment out this line, it works fine:
Link Posted: 04-Nov-2008 19:33
What is the exact scenario to reproduce this issue?
We do tests with Prototype, using prototype.js script include:
[code][/code]

What settings does your FlyTreeView instance have?
Could you post here a small test page that reproduces the conflict?
Link Posted: 05-Nov-2008 03:21
sorry, Evgeny.  I just re-read my post and it doesn't give you enough info
The treeview is set to load nodes dynamically via ajax/dhtml.  I get the error msg when I click on the node expand button and it tries to do the ajax call and update the tree.
I'll strip down a page so it can be reproduced...
Link Posted: 05-Nov-2008 03:57
aspx page: [code] <%@ Register Assembly="NineRays.WebControls.FlyTreeView" Namespace="NineRays.WebControls" TagPrefix="NineRays" %> Test treeview w/ prototype
[/code] Codebehind for page: [code] using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class TestTreeview : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { initTree(flyTree); } private void initTree(NineRays.WebControls.FlyTreeView tree) { NineRays.WebControls.FlyTreeNode topnode = new NineRays.WebControls.FlyTreeNode("top", "top"); topnode.PopulateNodesOnDemand = true; tree.Nodes.Add(topnode); } protected void flyTree_PopulateNodes(object sender, NineRays.WebControls.FlyTreeNodeEventArgs e) { tree_PopulateNodes(e.Node); } protected void tree_PopulateNodes(NineRays.WebControls.FlyTreeNode node) { NineRays.WebControls.FlyTreeNode subnode = new NineRays.WebControls.FlyTreeNode("child", node.ID+"child"); subnode.IsCheckbox = true; node.ChildNodes.Add(subnode); } } [/code] To reproduce the error, bring up the web page in a web browser (make sure it points to the prototype.js code which is included in the http://prototype-window.xilinus.com/themes.html library). Click on the + treeview expand button.
Link Posted: 05-Nov-2008 09:23
What I did:
1. Fixed Page_Load method to make it initialize FlyTreeView only when !IsPostBack.
2. Changed script reference to http://prototype-window.xilinus.com/javascripts/prototype.js (same one that is used by demo site of the library).

Tested in Firefox and IE7 (Vista) - everything looks okay, node successfully expands.
What exact version of FlyTreeView do you use?
Link Posted: 05-Nov-2008 10:16
I changed the tree to init once as well (this was only a bug in the test page, not the original);
if (!Page.IsPostBack)
        {
            initTree(flyTree);
        }

Also tried pointing the javascript src at the one on that web site.
I still get the same error msg on expanding that node in FF3 and MSIE7.

When I look at the flytreeview.dll in the project and in my flytree install directory, it claims it's version 4.3.1.54
Link Posted: 05-Nov-2008 11:57
I've attached a stack dump screen shot if that helps.

I've also tested this on another system with the same results (same binary though).
Please verify that the .js file was loaded by the browser.  If that .js file doesn't load, you won't get an error because whatever duplicate function name is in that .js file doesn't get loaded.  I thought this other system I tested on worked initially but when I pointed it at the full URL of the prototype.js file, it had the same error...
Link Posted: 05-Nov-2008 21:35
When I look at the flytreeview.dll in the project and in my flytree install directory, it claims it's version 4.3.1.54

Now its clear.
Starting from some version of FlyTreeView, we do compatibility tests with popular javascript frameworks.
I think that is the reason why you get issues with Prototype - your FlyTreeView version is too old (when FlyTreeView didn't contain these tests). That is why I do not get prototype issue with the current version.
Link Posted: 06-Nov-2008 03:39
Thanks, Evgeny.  What's the latest version of flytreeview?
According to your http://www.9rays.net/news.aspx?ProductFamilyID=7 page, it's 4.3 which is what we're running...

The latest downloadable trial version also appears to be 4.3?
Link Posted: 07-Nov-2008 03:52
Evgeny,

Can you tell me which version of flytreeview you started testing w/ Prototype?  And which version you're currently using?
I'm wondering whether we have to try switching to another javascript library...

thanks,

ken