jquery - Link to partial view inside another partial view -
i have main global layoutfile , in 1 of menu items link service catalog has it's own sidemenu generated model. here's simplified version of view:
@model ienumerable<service> <div class="row"> <div class="col-xs-4"> <div class="list-group"> <ul class="service-menu-list"> @foreach (var item in model) { <li> <a href="#@item.id" class="service-menu-link service-menu-item" id="serviceitem-@item.id"> <i class="service-menu-list-icon fa fa-chevron-right"></i> <span class="service-menu-list-text"> @item.name</span> </a> </li> } </ul> </div> </div> <div id="servicesmaincontainer" class="col-xs-8"> @html.partial("_servicesstart") </div>
this sidemenu generate partialview right depending on item you've clicked in menu. manage jquery ajax call looks this:
$(document).on("click", ".service-menu-link", function(e) { e.preventdefault(); var itemid = $(this).attr("id"); var container = $("#servicesmaincontainer"); var href = { href: $(this).attr("href") } removeactiveclass(); addactiveclass(itemid); $.ajax({ url: "@url.action("_showservice")", type: "post", cache: false, datatype: "html", contenttype: "application/json", data: json.stringify(href), error: function(jqxhr, textstatus, errorthrown) { alert("error: " + errorthrown.text()); }, success: function(result) { container.html(result).show(); } }); });
here's controllers main service page:
public actionresult services() { var db = new identitydb(); var servicelist = db.services.tolist(); return view("services", servicelist); }
...and partial view:
public actionresult _showservice(string href) { if (href == "#home") { return partialview("_servicesstart"); } else { var db = new identitydb(); var stringid = href.substring(href.indexof("#") + 1); var id = convert.toint32(stringid); var service = db.services.firstordefault(s => s.id == id); return partialview("_showservice", service); } }
my problem want link specific services index page, meaning want load services page menu specific service visible. if link services action, come starting area of service catalog, , can't link _showservice partial view because show partial view without css, layout , servicecatalog menu.
any ideas on how link partial view not lose main layout?
Comments
Post a Comment