-1
我有以下要求: - 有一个data_autocomplete_source传递额外的参数给我data_autocomplete_source
1.A文本框,如下: -
@ Html.TextBoxFor(型号=>模式。 Technology.Search,新{ data_autocomplete_source = Url.Action(“自动完成”,“开关”)})
2.两单选按钮来选择究竟是什么做的自动完成搜索关键字,按名称或号码如下: -
<input type="radio" name="searchType" value="number" /> number
<input type="radio" name="searchType" value="name"/>name
所以我的问题是否如何通过单选按钮选择,以及自动完成搜索词?
我的自动完成脚本看起来如下: -
$("input[data-autocomplete-source]").each(function() {
var target = $(this);
target.autocomplete({ source: target.attr("data-autocomplete-source"), minLength: 2, delay: 2000 });
});
编辑 我试过如下: -
@Html.TextBoxFor(model => model.Technology.Search, new { data_autocomplete_source = Url.Action("AutoComplete", "Switch", new { SearchBy = Model.SearchBy}) })
@Html.RadioButtonFor(a=>a.SearchBy, "number", new { id = "number" })number
@Html.RadioButtonFor(a=>a.SearchBy, "Name", new { id = "name" })Name
但SearchBy值将始终为空?
感谢