2015-02-06 79 views
-1

我必须通过下拉选择值的淘汰赛功能。我已经装箱剃刀语法为:如何将下拉列表中选定的值传递给knockout函数?

<div class="row"> 
     @Html.LabelFor(m => m.FilterByType, htmlAttributes: new { @class = "label" }) 
     @Html.DropDownListFor(m => m.FilterByType, new SelectList(Model.aspNetUser, "FilterByType", "FilterByName"), new { @class = "selectBox", @id = "aspnetUsersType", @data_bind = "event: {change: getData(0,'','',size,index,'')}" }) 
     <input type="hidden" id="filterByType" name="filterByType" value=""> 
    </div> 

以下是我的淘汰赛功能:

self.getData = function (filterbytype, fromdaterange, todaterange, pageSize, page, searchText) {"some task"} 

如何传入的getData选择的价值?现在我传递0作为filterbytype。

回答

0

假设使用的是在乌拉圭回合HTML这个下面的代码

<select data-bind="options: operations, value: self.selectedOperation"> 

确保您必须使用这些变量作为ko.observable()

所以乌尔JS代码将看起来像这样

var self = this; 
    self.selectedOperation = ko.observable("Option1"); // with self u can use more variables and here selectedOperation will be containing the choosen value you want and you can pass it wherever u want 
    var operations = ko.observableArray(["Option1", "Option2", "option3", "Opt4"]); // dropdown List 

现在它取决于你如何使用该变量..

相关问题