如何重用 kendo-combobox jquery 代码来制作多个输入框?
How can I reuse kendo-combobox jquery code to make multiple inputbox?
我想将 HTML Id、ActionName 传递给 jQuery 函数,该函数可以在该输入框上创建 kendo 组合框。我试过模块化 jQuery 方式,但没有任何帮助。也许我不能做到完美,但我尽力了。
<input class="form-control" name="" id="ddlId1">
<input class="form-control" name="" id="ddlId2">
我只传递 Id、ActionName、Text、Value
$myFunction("ddlId1","ActionName","Text","Value");
$myFunction("ddlId2","AnotherActionName","Text","Value");
我想创建 jQuery 函数,它将包含以下代码来创建 kendo 组合框
$("#"+ddlId+"").kendoComboBox({
placeholder: "Select Business Unit",
dataTextField: ""+Text+"", // may be I need to pass these two too.
dataValueField: ""+Value+"", //
filter: "contains",
autoBind: false,
minLength: 3,
dataSource: {
type: "jsondata",
serverFiltering: false,
transport: {
read: {
url: "/Promotion/"+ActionName+"",
}
}
}
});
这对我有用:
myFunction("ddlId1","ActionName","Text","Value");
function myFunction(Id,ActionName,Text,Value) {
$("#"+Id+"").kendoComboBox({
placeholder: "Select Business Unit",
dataTextField: ""+Text+"", // may be I need to pass these two too.
dataValueField: ""+Value+"", //
filter: "contains",
autoBind: false,
minLength: 3,
dataSource: {
type: "jsondata",
serverFiltering: false,
transport: {
read: {
url: "/Promotion/"+ActionName+"",
}
}
}
});
};
这只是改变函数传递变量方式的问题。
我想将 HTML Id、ActionName 传递给 jQuery 函数,该函数可以在该输入框上创建 kendo 组合框。我试过模块化 jQuery 方式,但没有任何帮助。也许我不能做到完美,但我尽力了。
<input class="form-control" name="" id="ddlId1">
<input class="form-control" name="" id="ddlId2">
我只传递 Id、ActionName、Text、Value
$myFunction("ddlId1","ActionName","Text","Value");
$myFunction("ddlId2","AnotherActionName","Text","Value");
我想创建 jQuery 函数,它将包含以下代码来创建 kendo 组合框
$("#"+ddlId+"").kendoComboBox({
placeholder: "Select Business Unit",
dataTextField: ""+Text+"", // may be I need to pass these two too.
dataValueField: ""+Value+"", //
filter: "contains",
autoBind: false,
minLength: 3,
dataSource: {
type: "jsondata",
serverFiltering: false,
transport: {
read: {
url: "/Promotion/"+ActionName+"",
}
}
}
});
这对我有用:
myFunction("ddlId1","ActionName","Text","Value");
function myFunction(Id,ActionName,Text,Value) {
$("#"+Id+"").kendoComboBox({
placeholder: "Select Business Unit",
dataTextField: ""+Text+"", // may be I need to pass these two too.
dataValueField: ""+Value+"", //
filter: "contains",
autoBind: false,
minLength: 3,
dataSource: {
type: "jsondata",
serverFiltering: false,
transport: {
read: {
url: "/Promotion/"+ActionName+"",
}
}
}
});
};
这只是改变函数传递变量方式的问题。