2015-02-06 93 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 

現在它取決於你如何使用該變量..

相關問題