jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – 如何使用MVC3在自动完成文本框中显示加载图像(动画.gif文件)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的asp.net MVC3应用程序中实现了自动完成文本框,但我无法在搜索期间在文本框中显示加载图像.
我的代码

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">

$(document).ready(function () {
    $("#txtPONO").autocomplete({
        source: "/Transection/GetPONO",minLength: 2,SELEct: function (event,ui) {
            $("#hdnPurcontid").val(ui.item.id);
        }
    });
});


</script>
<div style="float: left; padding: 9px 5px 5px 5px; width: 80px; vertical-align: middle"
                                class="fieldHead">
                                Enter @Html.LabelFor(l => l.PurchaseContract.AOPLPONO)
                            </div>
                            <div style="float: left; width: 200px; padding: 5px 0px 5px 0px;">
                                @Html.TextBoxFor(m => m.PurchaseContract.AOPLPONO,new { @id = "txtPONO",@class = "textBox",@style = "width:100%" })
                            </div>
                            <div style="float: left; width: 50px; padding: 4px 0px 0px 5px;">
                                <img alt="search" src="../../Content/images/Search.png" />
                                @Html.HiddenFor(model => model.PurchaseContract.Purcontid,new { @id = "hdnPurcontid" })
                            </div>

我想在右侧的文本框中显示一个小的加载图像

解决方法

像这样添加一个css类.

.loading
{
    BACkground:url('path to your image') no-repeat right center;
}

现在触发搜索选项并打开自动完成选项

$("#txtPONO").autocomplete({
        source: "/Transection/GetPONO",ui) {
            $("#hdnPurcontid").val(ui.item.id);
        },search: function(){$(this).addClass('loading');},open: function(){$(this).removeClass('loading');}

    });

要么

更好的解决方案就是使用css类

.ui-autocomplete-loading { BACkground:url('img/loading.gif') no-repeat right center }

jQuery ui-autocomplete-loading在加载期间自动运行加载图像

希望能帮助到你

大佬总结

以上是大佬教程为你收集整理的jquery – 如何使用MVC3在自动完成文本框中显示加载图像(动画.gif文件)全部内容,希望文章能够帮你解决jquery – 如何使用MVC3在自动完成文本框中显示加载图像(动画.gif文件)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。