2013-11-22 58 views
0

我想表明這應該對我們所點擊元素的值的警告消息,對於我已經寫了一些代碼,廣東話能夠訪問被點擊的元素值

<script type="text/javascript"> 
    function filterProducts() { 
     var clicked = this; 
     alert($(clicked).val()); 
     return { 
      Reference: $(this).val() 
     }; 
    } 


</script> 


@(Html.Kendo().DropDownList() 
    .Name("ReferenceValue") //The name of the dropdownlist is mandatory. It specifies the "id" attribute of the widget. 
    .DataTextField("ValidValue") //Specifies which property of the Product to be used by the dropdownlist as a text. 
    .DataValueField("ReferenceValidValueID") //Specifies which property of the Product to be used by the dropdownlist as a value. 
    .BindTo(Model) 
      .DataSource(source => 
      { 
       source.Read(read => 
       { 
        read.Action("GetReferenceValidValue", "GetData").Data("filterProducts"); //Set the Action and Controller name 
       }) 
       .ServerFiltering(true); //If true the DataSource will not filter the data on the client. 
      }) 
    .SelectedIndex(0) //Select first item. 
) 

但是,當點擊Dropdown,它不顯示在函數「filterProduct」中寫入的警報消息。

在那個時候它給了某種異常的一樣,

Cannot call method 'toLowerCase' of undefined 

回答

0
function filterProducts() { 
     var clicked = this;// this property not acccess like this 
     alert($(clicked).val()); 
     return { 
      Reference: $(this).val() 
     }; 
    } 

,你可以嘗試像

$("selector").click(function(){ 
^^^^here you can write $("button") and etc as your requirement 
      var clicked = this; 
      alert($(clicked).val()); 
      return { 
       Reference: $(this).val() 
      }; 

}): 
+0

我使用的劍道網格,你可以在上面看到,在我們的負載點擊下拉列表中的數據。 – Rahul