i have razor view with:
<select id="roletypeddl" > <option value="@roletype.id" selected="selected" data-assignabletoperson="@roletype.assignabletoperson" >@roletype.name</option> </select> so in jquery wanted run code if data-assignabletoperson true hence:
if ($('#roletypeddl').find('option:selected').data('assignabletoperson') == true) { } trouble code never getting executed.
i figure has html being produced being:
<select id="roletypeddl"> <option data-assignabletoperson="true" selected="selected" value="5">manufacturer</option> </select> i think problem "true" capitalised. know how around this?
data- attribute not know data type. @roletype.assignabletoperson html output true, not bool value, string...
following statement
data-assignabletoperson="true" is not bool value, string, should compare this:
if ($('#roletypeddl').find('option:selected').data('assignabletoperson') == "true") { } update: data knows data type. problem "true". must "true".
and example
Comments
Post a Comment