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

[Solved] Keep submenu visible and submit a form

2 Answers 34 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marcel
Top achievements
Rank 1
Marcel asked on 30 Aug 2011, 02:35 PM
1) In addition to the OpenOnClick(true) option on a Menu, is there also a possibility to always keep a submenu visible? Regardles to where the user clicks on a page, except when the user clicks on another submenu (and then keep that submenu visible).

2) Is there a way to have multiple links in the menu that post a form back to the controller? In this example to mimic a Save, SaveAndClose and SaveAndNew menuitem.

2 Answers, 1 is accepted

Sort by
0
Marcel
Top achievements
Rank 1
answered on 01 Sep 2011, 10:01 AM
1) Is still unresolved. I tried hooking to the onOpen event and stop event propagation but alas. Anyone?

2) I managed to hook the onSubmit, change the form url and submit the form. For anyone interested, here's the trick:

Razor view:
item.Add().Text("Save").SpriteCssClasses("save")
                    .LinkHtmlAttributes(new { @rel = "post" })
                    .Action("Edit", "Item", new { @id = Model.ItemID, saveAndClose = false, saveAndNew = false });
item.Add().Text("Save and Close").SpriteCssClasses("save-close")
                    .LinkHtmlAttributes(new { @rel = "post" })
                    .Action("Edit", "Item", new { @id = Model.ItemID, saveAndClose = true, saveAndNew = false });               
item.Add().Text("Save and New").SpriteCssClasses("save-close")
                    .LinkHtmlAttributes(new { @rel = "post" })
                    .Action("Edit", "Item", new { @id = Model.ItemID, saveAndClose = false, saveAndNew = true});

Controller: 
[HttpPost]
        [LayoutDefinition("_EditableViewLayout")]
        public ActionResult Edit(int id, bool saveAndClose, bool saveAndNew, Item item)
        {
                //     magic...
        }
             
jQuery
function onSelect(e) {
            var link = $(e.item).find('a');
 
            if (link.attr('rel') == 'post')
            {                   
                $('form').attr('action', link.attr('href'));                   
                $('form').submit();                   
 
                e.preventDefault();
            }               
        }
0
Chetan
Top achievements
Rank 1
answered on 13 Sep 2011, 02:04 PM
Hi,

If I only add Action in menu Item, anchor tag is not getting rendered in html.

Thanks,
Chetan
Tags
Menu
Asked by
Marcel
Top achievements
Rank 1
Answers by
Marcel
Top achievements
Rank 1
Chetan
Top achievements
Rank 1
Share this question
or