jquery - how to enable telerik dropdownlist -
i have telerik dropdownlist disables default:
<%= html.telerik().dropdownlist().name("yesno").enable(false) .items(items => { items.add().text("").value(""); items.add().text("yes").value("yes"); items.add().text("no").value("no"); })%>
now want enable when selects "no" telerik dropdown:
<%= html.telerik().dropdownlist().name("validate") .items(items => { items.add().text("").value(""); items.add().text("yes").value("yes"); items.add().text("no").value("no"); }) .clientevents(events => { events.onchange("validate_onchange"); })%>
so tried jquery method enable, not enabling ddl:
function validate_onchange(e) { if($("#validate").val() == "no"){ $('#yesno').attr('enable',true); } }
rendered mark validate ddl:
<div class="t-widget t-dropdown t-header" style="width:249px;" tabindex="0"> <div class="t-dropdown-wrap t-state-default"> <span class="t-input"> </span> <span class="t-select"> <span class="t-icon t-arrow-down">select </span> </span> </div> <input id="validate" name="validate" style="display:none" type="text"> </div>
you try removeattr
.
function validate_onchange(e) { if($("#validate").val() == "no"){ // enable $("#yesno").removeattr("disabled"); } else { // disable $("#yesno").attr("disabled", "disabled"); } }
updated
<%= html.telerik().dropdownlist().name("yesno").enable(false) .items(items => { items.add().text("").value(""); items.add().text("yes").value("yes"); items.add().text("no").value("no"); })%> <%= html.telerik().dropdownlist().name("validate") .items(items => { items.add().text("").value(""); items.add().text("yes").value("yes"); items.add().text("no").value("no"); }) .clientevents(events => { events.onchange("validate_onchange"); })%> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> function validate_onchange(e) { if ($("#validate").val() == "no") { $("#yesno").data("tdropdownlist").enable(); } else { $("#yesno").data("tdropdownlist").disable(); } } </script>
Comments
Post a Comment