MVC 5 TreeView vavolo alert

Mar 27, 2014 at 4:10 AM
Hi,

I'm trying to create a project using MVC 5 and the Treeview control. I used VS 2013 MVC template as a starting point and manually added the references to the controls toolkit.
Being a little inexperienced with MVC/web development I had a few initial issues. I have finally gotten to a point where I don't know where to look next.

It seems to render correctly, the issue is when I expand the root treeview node in edit mode it is raising an alert which is a little annoying. I was wondering if anyone had any ideas as to what is causing it. Any help would be much appreciated.

Included scripts
    @Scripts.Render("~/Scripts/jquery-1.10.2.js")
    @Scripts.Render("~/Scripts/jquery-ui-1.10.4.custom.min.js")
    @Scripts.Render("~/Scripts/jquery.treeview.all-2.4.0.min.js")
    @Scripts.Render("~/Scripts/MVCControlToolkit.Controls-2.4.5.min.js")
Treeview code (yes I used the example as a starting point)
<div id="treetobind">

        @Html.TreeViewFor(
            m => m.Locations,
            i => i == 0 ? "Locations" : null,
            ExternalContainerType.span,
            null, // "filetree treeview-red treeToedit",
            new object[] {
                _S.L<RegionElement>(h => 
                    "<span class='region'>" + h.DisplayFor(m => m.Name).ToString() + "</span>"),
                _S.L<LocationElement>(h => 
                    "<span class='location'>" + h.DisplayFor(m => m.Name).ToString() + "</span>")
                },
            (x, y) => x is RegionElement ? 0 : 1,
            null, // "filetree treeview-red treeToedit",
            new object[] {
             _S.L<RegionElement>(h => string.Format(
                     "<div class='region' >{0} {1} {2} {3}</div>",
                     h.TypedEditDisplayFor(m => m.Name, simpleClick: true).ToString(),
                     h.TreeViewDeleteButton(Url.Content("~/Content/folder_delete_16.png"),
                         ManipulationButtonStyle.Image).ToString(),
                     h.TreeViewAddButton(1, Url.Content("~/Content/document_add_16.png"),
                         ManipulationButtonStyle.Image).ToString(),
                     h.Hidden("IsFolder", true).ToString())),
                            
                _S.L<LocationElement>(h => string.Format(
                    "<div class='location' >{0} {1} {2}</div>",
                    h.DisplayFor(m => m.Name).ToString(),
                    h.TreeViewDeleteButton(Url.Content("~/Content/document_delete_16.png"), 
                        ManipulationButtonStyle.Image).ToString(),
                    h.Hidden("IsFolder", false).ToString())) 
            },
            (x, y) => x is RegionElement ? 0 : 1,
            TreeViewMode.InitializeDisplay,
            (x) => "allnodes",
            (x, y) => TreeViewItemStatus.Hide
        )

    </div>
             
    <div>
        @Html.TreeViewToggleEditButtonFor(
            m => m.Locations,
            "Edit Folders", "TreeViewEdit",
            "Undo Changes", "TreeViewUndo",
            "Redo Changes", "TreeViewRedo")
    </div>
Model being used in the page
    public class LocationModel : ISafeCreation
    {
        [Required, Format(NullDisplayText = "empty name")]
        public String Name { get; set; }
    }

    public class RegionElement : LocationModel
    {
        public IList<LocationElement> Locations { get; set; }
    }

    public class LocationElement : LocationModel
    {

    }

    public class testModel
    {
        public List<LocationModel> Locations { get; set; }
    }
Snippet of generated code with the alert
 <script language='javascript' type='text/javascript'>
                var Locations___Choice2___flattened___0_RootNamePostfix='Locations___Choice2___flattened';
                
                $(document).ready(function()
                {
                    var jQueryRoot = $('#Locations___Choice2___flattened___0_ItemsContainer');
                    jQueryRoot.parent().children('div.hitarea').click(function(){
                        alert('vavolo');
                        if (jQueryRoot.hasClass('ui-sortable')) return true;
                        jQueryRoot.sortable({ handle: '.Locations___Choice2___flattened___0_handle',     connectWith: '.allnodes_Locations___Choice2___flattened',  
                                    update: function(event, ui) {MvcControlsToolkit_TreeView_UpdatePermutations(ui.item, 'Locations___Choice2___flattened___0_ItemsContainer'); },
                                    start:  function(event, ui) {MvcControlsToolkit_TreeView_StartDrag(ui.item, jQueryRoot);},
                                    stop:   function(event, ui) {MvcControlsToolkit_TreeView_StopDrag(ui.item, jQueryRoot);}
                                    });
                        return true;
                        });
                    
                });
            </script>
Coordinator
Mar 27, 2014 at 1:54 PM
Hi Krypt,
It is a bug. we added this alert while debugging the code, to resolve an issue, and then someone forgot to clean up the code.
Next week we will put on line the corrected dlls, both on nuget and on codeplex.
Marked as answer by Krypt on 3/27/2014 at 6:04 PM
Mar 28, 2014 at 1:04 AM
Cool, thanks for the quick reply
Coordinator
Mar 31, 2014 at 2:16 PM
New bug fixed 2.55 release available both on nuget and in the download aread (UpdatedBinaries file).