1

Delete catgories from DOM

This commit is contained in:
Alex Yatskov 2015-03-12 10:38:33 +09:00
parent 7bdf03f159
commit 8f01c714e4
2 changed files with 10 additions and 6 deletions

View File

@ -18,19 +18,19 @@
<tbody id="categories"></tbody> <tbody id="categories"></tbody>
<script id="template" type="text/x-handlers-template"> <script id="template" type="text/x-handlers-template">
{{#each categories}} {{#each categories}}
<tr> <tr class="category_{{id}}">
<td class="text-left">{{description}}</td> <td class="text-left">{{description}}</td>
<td class="text-right"> <td class="text-right">
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="category_{{id}}" data-categoryId="{{id}}" value="1" {{checkMatch 1}}> Agree <input type="radio" name="category_{{id}}" data-categoryId="{{id}}" value="1" {{checkMatch 1}}> Agree
</label>&nbsp; </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="category_{{id}}" data-categoryId="{{id}}" value="-1" {{checkMatch -1}}> Disagree <input type="radio" name="category_{{id}}" data-categoryId="{{id}}" value="-1" {{checkMatch -1}}> Disagree
</label>&nbsp; </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="category_{{id}}" data-categoryId="{{id}}" value="0" {{checkMatch 0}}> Neither <input type="radio" name="category_{{id}}" data-categoryId="{{id}}" value="0" {{checkMatch 0}}> Neither
</label>&nbsp; </label>
<button type="button" data-categoryId="{{id}}" class="btn btn-xs btn-danger">&times;</button> &nbsp;<button type="button" data-categoryId="{{id}}" class="btn btn-xs btn-danger">&times;</button>
</td> </td>
</tr> </tr>
{{/each}} {{/each}}

View File

@ -51,7 +51,11 @@
} }
function removeCategory(id) { function removeCategory(id) {
alert('Delete stub'); $.getJSON('/forget', {id: id}, function(results) {
if (results.success) {
$('tr.category_' + id).remove();
}
});
} }
function displayCategories(categories) { function displayCategories(categories) {