【发布时间】:2017-12-24 13:51:28
【问题描述】:
我在尝试获取所选对象而不是传递给成功回调的“newValue”时遇到问题。
这是一个例子:
$("select").editable({
type : "select",
title: 'Select Fruit',
source : [
{text : "Apple", value: "option_1"},
{text : "Orange", value: "option_2"},
{text : "Mango",value: "option_3"},
{text : "Strawberry",value: "option_4"}
],
success:function(response,newValue){
console.log(newValue); // newValue contains the "text" string ok..
// How do I get the selected source object? eg. {text : "Orange", value: "option_2"}
// So I can access the object like..
console.log(newValue.value); // output option_*
}
});
谢谢 卡尔
【问题讨论】:
-
你看到console.log(response)了吗?
-
是的,我试过了,那是来自 Ajax 请求的响应(我没有使用)
-
@CarlSmith 可以做这个吗?
标签: javascript jquery x-editable