Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 调用Show()时停止JQuery元素在错误位置显示元素?_C#_Jquery_Model View Controller_Jquery Ui - Fatal编程技术网

C# 调用Show()时停止JQuery元素在错误位置显示元素?

C# 调用Show()时停止JQuery元素在错误位置显示元素?,c#,jquery,model-view-controller,jquery-ui,C#,Jquery,Model View Controller,Jquery Ui,我有一个包含3个单选按钮列表的页面和一个用于选择报告的jqueryUI按钮 但是,按钮在第一次出现时并没有出现在正确的位置。我不知道为什么 要显示的第二次/后续调用将按钮移动到其正确位置。 移除显示:从css中移除按钮会从一开始就将其放置在正确的位置,所以我不知道为什么它会出现在错误的位置 为大量代码道歉-我已将所有内容放在一个视图中进行演示: <style type="text/css"> .fieldset_Rule { display: inline;

我有一个包含3个单选按钮列表的页面和一个用于选择报告的jqueryUI按钮

但是,按钮在第一次出现时并没有出现在正确的位置。我不知道为什么

要显示的第二次/后续调用将按钮移动到其正确位置。 移除显示:从css中移除按钮会从一开始就将其放置在正确的位置,所以我不知道为什么它会出现在错误的位置

为大量代码道歉-我已将所有内容放在一个视图中进行演示:

<style type="text/css">
    .fieldset_Rule
{
    display: inline;
    vertical-align:top;
}
.fieldset_Rule legend
{
    font-size: 1em;
}
.radio_Rule
{
    margin-right: 10px;
}
.fieldset_Accounts
{
    display: inline;
    vertical-align:top;
}
.fieldset_Accounts legend
{
    font-size: 1em;
}
.radio_Accounts
{
    margin-right: 10px;
}
.fieldset_Display
{
    display: inline;
    vertical-align:top;
}
.fieldset_Display legend
{
    font-size: 1em;
}
.radio_Display
{
    margin-right: 10px;
}
span#reportlink
{
    margin-top:10px;
    padding: .4em 1em .4em 20px;
    text-decoration: none;
    cursor: default;
    position:absolute;
    display:inline;
    float:left;
}

span#reportlink span.ui-icon
{
    margin: -8px 5px 0 0;
    left: .2em;
    top: 50%;
    float: left;
    position: absolute;
}

span#reportlink:hover
{
    cursor: pointer;
    color: #0060a9;
}

div.reportloading
{
    padding: 10px;
    color: #002c5a;
    font-size: 1.5em;
}

span.reportloadingtext
{
    background-position: left center;
    background-image: url('ajax-loader.gif');
    background-repeat: no-repeat;
    padding-left: 40px;
    padding-top: 15px;
    padding-bottom: 15px;
}
</style>
<script src="../../Scripts/jquery-1.6.4.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.16.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.blockUI.js" type="text/javascript"></script>
<link href="../../Content/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
    /// <reference path="jquery-1.6.4-vsdoc.js" />
    var rule = '';
    var accounts = '';
    var display = '';
    var url = '';

    $(document).ready(function () {

        $('#reportlink').click(function () {
            $.blockUI({
                message: '<div class="reportloading"><span class="reportloadingtext">Loading Report...</span></div>'
            }
                );
            $(location).attr('href', url);
        });

        $('input[name="Rule"]').change(function () {
            rule = $(this).val();
            SetReportLink();
        });

        $('input[name="Accounts"]').change(function () {
            accounts = $(this).val();
            SetReportLink();
        });

        $('input[name="Display"]').change(function () {
            display = $(this).val();
            SetReportLink();
        });

        $('#reportlink').toggle();
    });

    function SetReportLink() {
        url = '/TestMvc/' + rule + '/report/' + accounts + "/" + display;
        if (rule != '' && accounts != '' && display != '') {
            $('#reportlink').show('fast');
            $('#reportlink').hover(
                    function () { $(this).addClass('ui-state-hover'); },
                    function () { $(this).removeClass('ui-state-hover'); }
                );
        }
    }
</script>
<h2>
    Please select one option from each of the following:
</h2>
<fieldset class="fieldset_Rule"><legend>Rule Type</legend>
<div class="radio_Rule"><input id="Rule_I" name="Rule" type="radio" value="I" /><label for="Rule_Irs">I</label></div>
<div class="radio_Rule"><input id="Rule_L" name="Rule" type="radio" value="L" /><label for="Rule_Liquid">L</label></div>
</fieldset>

<fieldset class="fieldset_Accounts"><legend>Accounts</legend>
<div class="radio_Accounts"><input id="Accounts_All" name="Accounts" type="radio" value="All" /><label for="Accounts_All">All</label></div>
<div class="radio_Accounts"><input id="Accounts_Local" name="Accounts" type="radio" value="Local" /><label for="Accounts_Local">Local</label></div>
</fieldset>

<fieldset class="fieldset_Display"><legend>Display As</legend>
<div class="radio_Display"><input id="Display_Equivalent" name="Display" type="radio" value="Equivalent" /><label for="Display_Equivalent">Equivalent</label></div>
<div class="radio_Display"><input id="Display_Natural" name="Display" type="radio" value="Natural" /><label for="Display_Natural">Natural</label></div>
</fieldset>

<span id="reportlink" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-search">
</span>Get Report</span>

非常感谢您的帮助

调用show时,display:block样式将应用于该元素。因此,如果是内联元素,请避免使用show和do

$("selector").css('display','inline');