我有一個包含標準元素的_Layout
頁面。如何從部分視圖中獲取_Layout頁面中的元素
<body id="layoutBody">
<div class="wrapper">
@Html.Partial("_TopMenu")
@Html.Partial("_LeftMenu")
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<!-- Main content -->
<section class="content">
@RenderBody()
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<footer class="main-footer">
<div class="pull-right hidden-xs">
<b>Version</b> 1.0
</div>
</footer>
</div><!-- ./wrapper -->
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap"
</body>
這裏面的佈局我有一個「家」,「指數」的@RenderBody
內頁有以下DIV:
<div class="small-box bg-yellow">
<div class="inner">
<h4>Phone Directory</h4>
<h5>New</h5>
</div>
<div class="icon">
<i class="mi mi-contact-phone"></i>
</div>
<a id="newUserCollapse" role="button" class="list-group-item" data-toggle="collapse" data-target="#new">
<span class="glyphicon glyphicon-chevron-right"></span>
Add New User
<span class="fa fa-user-plus pull-right"></span>
</a>
<div id="new" class="sublinks collapse">
<iframe src="~/PhoneMasters/Create" id="addUserIframe" align="middle" frameborder="0" style="width: 100%; height :100%; min-height: 600px; padding-top: 0px"></iframe>
</div>
</div>
我所試圖做的是在_Layout
禁止滾動當newUserCollapse
在show.bs.collapse
上時查看。 任何可以完成的方式?
在此先感謝!
謝謝你的答案。但是,問題是我試圖從一個局部視圖調用這個來獲取_Layout頁面中的元素。您提供的解決方案將起作用,如果它是相反的。 – 1moreLearner
@ 1moreLearner我相信,當你使用Document時,你閱讀** All **頁面的元素,所以無所謂你在哪裏打電話。你有沒有試圖實現這一點? –
我想我找出了問題所在。如果我從$('#newUserCollapse')。on('show.bs.collapse',function(){to $('#newUserCollapse')。click(function()您的解決方案工作。理解爲什麼,因爲我在該元素中有一個data-toggle =「collapse」現在,如果我離開了click事件,滾動條會保持禁用狀態,這不是我想要的,我仍然希望切換功能就位。 – 1moreLearner