-2

I wonder if someone could help me please....I'm just starting out in MVC and I've been asked to build a page (VS2013, MVC4 and Umbraco 7) in the following format. Basically I need to build a page in contains an accordion with 4 levels.

The first level is built from what's incoming off the querystring and displays to the user a radiobutton list. I done this part insomuch that I getting the data in the controller and returning this IEnumerable to the View and displaying it to the user.

My problem is that the level 2 should be populated with what the user has selected in level 1 (and level 3 from what they were to select in level 2, etc.) and I just don't know how to go about building this.

I can't really put any code examples up as I don't know what to start writing (!) could anyone point me in the right direction or tell me what structure I need to start building in my page please?

thanks, Craig

tereško
  • 58,060
  • 25
  • 98
  • 150
SxChoc
  • 619
  • 3
  • 10
  • 26

1 Answers1

0

What you need to do is look at loading a partial view via an AJAX request after the selections have been made.

    var Selection1 = $(".Selection1RadioButton").val();
    $.ajax({
    type: "GET",
    url: "/Home/GetSomePartialView?Selection1=" + Selection1,
    data: someArguments,
    success: function (viewHTML) { 
        $("#someDiv").html(viewHTML); 
    },
    error: function (errorData) { onError(errorData); }
    });

And repeat for Selection 2.

Rob Carroll
  • 377
  • 1
  • 7
  • 16
  • Cheers for that rob (this whole MVC thing is like black magic to my webformed trained mind). I think that I understand what you're getting at. But the only way to find out is give it a go! Just a quick thing though I need to always keep what the user has selected populated.....this still OK with this approach? – SxChoc Jul 16 '15 at 14:53
  • Yes create three divs and only update the div2 with the html that comes back after making the selection in div1. You don't want to overwrite the whole section. Just update a section. – Rob Carroll Jul 16 '15 at 14:58
  • I was on webforms for awhile and converted to MVC about 2.5 years ago. If you're happy with the answer don't forget to mark it as accepted. If you have any other questions, don't hesitate to reach out, more than happy to help decode MVC for you and point you in the right direction. – Rob Carroll Jul 16 '15 at 14:58
  • Cheers rob, I'm literally building this now (or trying to!) so I'll be back in minute after I've broken something! – SxChoc Jul 16 '15 at 15:05