gpt4 book ai didi

jquery - 如何使用 MVC3 在自动完成文本框中显示加载图像(动画 .gif 文件)

转载 作者:行者123 更新时间:2023-12-03 22:56:51 26 4
gpt4 key购买 nike

我已经在我的 asp.net MVC3 应用程序中实现了自动完成文本框,但我无法在搜索过程中显示在文本框中加载图像。我的代码是

Javascript

<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>

View

<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",
minLength: 2,
select: function (event, 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 文件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15774710/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com