我有一个jQuery模式,如果满足条件语句,我想添加一个额外的按钮.
原始示例代码(缩减):
$("#dialog").html("<div></div>").dialog({
title: "Some Title",
modal: true,
width: 550,
buttons: {
Ok: function() {
//
},
'A Button': function() {
//
}
}
}).dialog('open');
Run Code Online (Sandbox Code Playgroud)
因此,正如您在上面看到的那样,有一个带有2个按钮的模态,但我还想添加一些动态代码,以便在设置变量时能够满足额外的按钮.例如
var some_variable = 0;
$("#dialog").html("<div></div>").dialog({
title: "Some Title",
modal: true,
width: 550,
buttons: {
Ok: function() {
//
},
'A Button': function() {
//
}
/* ??? */
if (some_variable==1) //then add the other button's code here..
/* ??? */
}
}).dialog('open');
Run Code Online (Sandbox Code Playgroud) 使用官方ElasticSearch Python 库(文档)
我创建一个索引:
doc = {
"something": "123a",
"somethingelse": "456b",
"timestamp": datetime.now(),
"history": []
}
es.index(index="someindex", doc_type="somedoctype", id="someid", body=doc)
Run Code Online (Sandbox Code Playgroud)
我想每次都将项目附加到历史记录中,而不是覆盖它们:
es.update(index="someindex", doc_type="somedoctype", id="someid",
body={"doc": {
"history": {
"123abc": "abc", "456def": "def", "timestamp": datetime.now()
}
}
})
Run Code Online (Sandbox Code Playgroud)
我必须在第二个代码片段中更改什么才能将其附加到历史记录数组/列表中,而不是每次都覆盖它?