如何刷新局部视图而不MVC刷新整个页面 [英] how to refresh partial view without refreshing the complete page in mvc

查看:281
本文介绍了如何刷新局部视图而不MVC刷新整个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我M在我的应用程序中使用Ajax的Tab平板。
共有4个标签左手边和右手边的局部视图。
在这些选项卡中的余米显示了一些数据,并有每个选项卡上选择一个链接按钮。
当我点击任何选择链接按钮我为填充一些信息的部分观点。
发生这种情况时我的看法是完全地再次加载。
A B C D

I m using a Ajax Tab panel in my application. There are 4 tabs on Left hand side and a partial view on right hand side. In each of these tab I m displaying some data and there is a select link button on each tab. when I click on any of the select link button I m filling the partial view with some information. When this happens my view is completly loaded again. A B C D

例如,这些都是标签。
让我们假设我米选项卡上的B和现在当我点击选择链接按钮我的看法是完全地加载信息。
但该选项卡松此时的焦点。我回来的默认值。
所以我想在这个帮助
1)要么我必须只刷新局部视图,而无需加载整个页面
2)或我需要保持对点击选择链接按钮活动标签索引值
请帮我解决这个问题
并提供我的例子

eg these are the tabs. let us suppose that I m on tab B and now when I click on the select link button My view is completly loaded with information. but the tab loose the focus at this point. I comes back to the default value. so I want help on this 1) either I have to refresh only the partial view without loading the complete page 2) or I need to maintain active tab index value on click on select link button Please help me with this problem and provide me examples

推荐答案

的Jquery Tabs-加载内容只有当点击
 下面是示例中的标签加载哪些内容动态阿贾克斯。这是PHP,你需要改变什么放在控制器/动作,而不是PHP页面的URL的。

Jquery Tabs- Load Contents only when clicked Here is the example which loading content of the tabs dynamically by Ajax. It is for PHP what you need to change is put controller/action instead of URL of the PHP page.

$.get("controller/action", {tab_clicked, "my_tab"}, tab_fetch_cb, "text/json/xml");

否则,而不是Ajax.ActionLink的

or else instead of Ajax.ActionLink

使用<一的onclick =LoadTab(@ item.ID)>项目@ item.ID< / A>
 和jQuery功能更改选项卡并加载数据dyanamicaly

use <a onclick="LoadTab(@item.ID)">Item @item.ID</a> and jquery function to change the tab and load data dyanamicaly

function LoadTab(id){
     //Change tab here Ex: $('#tabs').tabs('select', index);
      $.get('ajax/test.html', {Id, id},function(data) {
          $('#Partial_Controller_Name').html(data);

      });

}

这篇关于如何刷新局部视图而不MVC刷新整个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆