I have below html layout. When i enters a, b or c in to the text box (#txtprevent). i need to stop the user from selecting the specific item which has the data-attribute value. e.g.: if i enter b. i should not be allowed to select b. The problem have is event.preventDefault(); is not stopping the selection action. If this the expected functionality.
If there a different workaround for this?
Below is my Html
<input id="txtprevent" type="text">
<table id="mySelectable" class="ui-selectable">
<tbody><tr id="1" data-myapp="a" class="ui-selectee">
<td>Row 2</td>
</tr>
<tr id="2" data-myapp="b" class="ui-selectee">
<td>Row 3</td>
</tr>
<tr id="3" data-myapp="c" class="ui-selectee">
<td>Row 1</td>
</tr>
</tbody></table>
My js
$(function () {
$('#mySelectable').selectable({
filter: "tr",
selecting: function (event, ui) {
var item = $(ui.selecting);
var itemVal = item.prop('data-myApp');
if(itemVal == $('#txtprevent').val()){
//does not stop the selection process
event.preventDefault();
}
}
});
});