I have an unordered list of list items that each contain a button. When this button is clicked, I want my dialog box to open for the associated list item. Each list item has unique text that the dialog box should display.
Here's my html
<ul id="filter-list" class="scrollable-menu text-center">
@foreach (var filter in Model.GlobalFilters)
{
<li class="form-inline" data-id="@filter.FilterId.ToString()" style="margin-bottom: 8px">
<button type="button" class="description-button" title="View/Edit Description" style="background-color:transparent;">
<i class="fa fa-sticky-note fa-2x" aria-hidden="true"></i>
</button>
<textarea type="text" class="description" title="Filter Description" style="display: none">@filter.Description</textarea>
</li>
}
</ul>
And here's my JQuery
$(document).ready(function () {
$('.description').dialog({
autoOpen: false,
buttons: {
'OK': function () {
//var name = $('input[name="Description"]').val();
//storeData(name);
$(this).dialog('close');
},
'Cancel': function () {
$(this).dialog('close');
}
}
})
$('button.description-button').on('click', function () {
$(this).siblings('.description').dialog('open');
})
});
I was hoping that the jquery dialog init would be done for every single list element that my foreach loop generates, but it seems to only be done on the first element. Furthermore, the dialog doesn't even open for the first element when I click the button.
Any insight here would be greatly appreciated. Still very new to all things web development!