【问题标题】:MVC Beginform action = goto anchor/id on pageMVC Beginform action = 转到页面上的锚点/id
【发布时间】:2012-06-20 15:21:57
【问题描述】:

我有一个 MVC beginform(带有 JQUERY UI MOBILE 和 AJAX。)当用户点击提交时, 我想在页面上显示**<div data-role="page" id="two">**

@using (Html.BeginForm())
{

<div data-role="page" id="one">
<div data-role="header">Header stuff</div><!-- /header -->
<div data-role="content" >  
<div class="ui-body ui-body-b">
.....DATA......
<input type="submit" value="Submit" />
</div></div><div>

<div data-role="page" id="two">
<div data-role="header">Header stuff2</div><!-- /header -->
<div data-role="content" >  
<div class="ui-body ui-body-b">
FINISH
</div></div><div>



}

【问题讨论】:

    标签: c# asp.net-mvc jquery-ui jquery


    【解决方案1】:

    我刚刚遇到这个问题,发现我无法从 MVC 的控制器返回锚标记。所以,我从控制器传回的参数重定向用户:

    if( getParameterByName("anchorID") != null) { 
        location.href = '#' + getParameterByName("anchorID");
    } 
    
    function getParameterByName(name) { 
        var match = RegExp('[?&]' + name + '=([^&]*)') 
                        .exec(window.location.search); 
        return match && decodeURIComponent(match[1].replace(/\+/g, ' ')); 
    

    那么你应该可以在点击提交后查看你的div。

    【讨论】:

    • 当我有 location.href = '#two' 时,我得到空白页说“未定义”
    猜你喜欢
    • 1970-01-01
    • 2023-04-02
    • 2015-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-03
    • 2011-03-06
    • 2013-09-08
    相关资源
    最近更新 更多