Jquery tabs with mvc partial views [closed]

早过忘川 提交于 2019-12-13 09:54:41

问题


Is it possible to preload actions from the controller through tabs of jquery so that all the tabs are preloaded in html and do not reload the page when you click on the tab?

Nonetheless, I am trying to have the html for each tab already loaded on the page so when you navigate through the tabs you dont need to reload to retrieve data.


回答1:


This doesn't really have anything to do with actions, it's just a matter of including the desired content in your view. It could be as simple as this:

<div id="tabs">
  <ul>
    <li><a href="#tabs-1">first tab</a></li>
    <li><a href="#tabs-2">second tab</a></li>
    <li><a href="#tabs-3">third tab</a></li>
  </ul>
  <div id="tabs-1">
    first tab content
  </div>
  <div id="tabs-2">
    second tab content
  </div>
  <div id="tabs-3">
    third tab content
  </div>
</div>

If your views are organized such that the tabs' contents are in partial views, just render those partial views in those tabs:

<div id="tabs">
  <ul>
    <li><a href="#tabs-1">first tab</a></li>
    <li><a href="#tabs-2">second tab</a></li>
    <li><a href="#tabs-3">third tab</a></li>
  </ul>
  <div id="tabs-1">
    @Html.Partial("FirstTabView", Model)
  </div>
  <div id="tabs-2">
    @Html.Partial("SecondTabView", Model)
  </div>
  <div id="tabs-3">
    @Html.Partial("ThirdTabView", Model)
  </div>
</div>

Ultimately this is just about defining the view in the output. The controller actions are to handle further input.



来源:https://stackoverflow.com/questions/22483212/jquery-tabs-with-mvc-partial-views

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!