2

I want to pass HTML Id, ActionName to a jQuery function that can make a kendo comboBox on that input box. I've tried modular jQuery way but nothing helped me. Maybe I couldn't make that perfectly, but I tried my best.

<input class="form-control" name="" id="ddlId1">

<input class="form-control" name="" id="ddlId2">

I'll pass just Id, ActionName, Text, Value

$myFunction("ddlId1","ActionName","Text","Value");
$myFunction("ddlId2","AnotherActionName","Text","Value");

I want to make jQuery function which will contain following code to make kendo combobox

$("#"+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+"",
                    }
                }
            }
        });
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Akash Khan
  • 33
  • 1
  • 5

1 Answers1

0

This worked for me:

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+"",
                }
            }
        }
    });
    };

It was just o question of changing how you function pass the variables.

CMartins
  • 3,247
  • 5
  • 38
  • 53