我正在尝试实现tag-it输入,但我想限制用户只从自动完成框中选择值.我尝试使用源json覆盖beforeTagAdded事件,并检查源属性中是否存在标记,但没有运气.
这是代码,请参阅beforeTagAdded函数.
$(document).ready(function () {
var itemId;
var theTags = $('#msg_to');
theTags.tagit({
autocomplete: {
source: [{ id: "1", value: 'David'}, { id: "2", value: 'John' }],
minLength: 0,
select: function (event, ui) {
itemId = ui.item.id;
theTags.tagit("createTag", ui.item.value);
}
},
showAutocompleteOnFocus: true,
afterTagAdded: function (event, ui) {
if (itemId) {
$(ui.tag).find('input').attr('name', "tag[\'" + itemId + "']['" + ui.tagLabel + "']");
itemId = null;
}
},
beforeTagAdded: function (event, ui) {
var id = ui.autocomplete.source; // not working
// what to …Run Code Online (Sandbox Code Playgroud) 我已经设置了与 DynamoDB 的 API 端点集成。我想使用查询字符串参数作为查询过滤器来查询表。不幸的是,我最终得到了错误:
Method response body after transformations: {"__type":"com.amazon.coral.service#SerializationException"}
Run Code Online (Sandbox Code Playgroud)
不知道根本原因是什么。
为了做到上述,我采取了以下步骤:
1)在API网关中设置get方法
2)在方法请求中,我向 URL 查询字符串参数添加了一个参数

3) 在集成请求中,我在 URL 查询字符串参数中添加了与步骤 2 相同的参数

4)在 DynamoDB 表中,我为要查询的列添加了一个新索引
5)在身体映射模板中:
{
"TableName": "tjusers",
"IndexName" "badge-index",
"KeyConditionExpression": "badge = :v1",
"ExpressionAttributeValues": {
":v1": {
"S": "$input.params('badge')"
}
}
}
Run Code Online (Sandbox Code Playgroud)
例外:
xecution log for request f0081606-b521-11e8-adb2-cd8092221b33
Mon Sep 10 17:50:00 UTC 2018 : Starting execution for request: f0081606-b521-11e8-adb2-cd8092221b33
Mon Sep 10 17:50:00 UTC 2018 : HTTP Method: GET, Resource Path: /db/users
Mon Sep 10 17:50:00 …Run Code Online (Sandbox Code Playgroud) 我一直试图将模型传递给带有表单的局部视图.某些模型字段已在GET请求中分配.当表单加载时,我可以看到模型字段值,但在提交表单后,我在此行中收到此错误:@Html.Hidden("From",Model.From):
你调用的对象是空的
为什么这两个字段在提交时被赋值为null?
我的控制器:
[HttpGet]
public ActionResult SendPrivateMessage(string from, List<string> to)
{
// two of the fields are already assigned
return PartialView("SendMessage", new MessageModel(from,to));
}
[HttpPost]
public ActionResult SendPrivateMessage(MessageModel m)
{
string fullname = "";
LoginModel loginData = (LoginModel)(Session["user"]);
if (Session["user"] != null)
{
fullname = loginData.LoginDS.Tables[0].Rows[0][loginData.LoginDS.Tables[0].Columns["fullname"].Ordinal].ToString();
}
m.fullname = fullname;
m.Send();
return PartialView("SendMessage");
}
Run Code Online (Sandbox Code Playgroud)
局部视图:
@model HaifanetMobile.Models.MessageModel
<div id="contact_form">
<a id="back_contact" href="#" style="float:left">
<img style="height:20px; width:30px;" src="~/Images/back_btn.gif" alt="back" />.
</a>
<div id="contactus_title">
<div id="close_contactus" style="float:right"><img style="height:20px; width:20px;" src="~/Images/close_btn.gif" …Run Code Online (Sandbox Code Playgroud)